360 Secure SkillHub
360 安全技能中心

Agnes Image 2.0 Flash

调用 Agnes Image 2.1 Flash 的 OpenAI 兼容图像接口:按文本提示生成图片,或基于输入图片做图生图编辑,返回图片链接或 base64 数据,并可用附带的 Python 脚本保存到本地。使用前需自行配置 API 密钥。

lutongsuo
lutongsuo
热度 13.01
最近更新 2026-07-05 18:30:55
分类:创作依赖:第三方 API / 代码执行 / 读写文件应用场景:图像生成 / API 集成 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add agnes-image
Metadata
name
agnes-image
description
Generate or edit images using Agnes Image 2.1 Flash via OpenAI-compatible images API. Supports text-to-image and image-to-image (img2img) generation. Use this skill when the user asks to: generate an image, create AI art, draw/paint with AI, edit an image with AI, do image-to-image translation, use Agnes for image generation. Triggers: 生成图片, AI绘画, 文生图, 图生图, Agnes图片, agnes-image, generate image, create picture.
agent_created
true

Agnes Image — Agnes Image 2.1 Flash 图像模型

Overview

Agnes Image 2.1 Flash is Sapiens AI's free image generation model with an OpenAI-compatible images API. Supports text-to-image generation and image-to-image editing.

  • Model ID: agnes-image-2.1-flash
  • Base URL: https://apihub.agnes-ai.com/v1
  • Pricing: ~$0.003/image (free tier available)
  • Auth: Authorization: Bearer YOUR_API_KEY
  • Generate endpoint: POST /v1/images/generations

Quick Start

API key from AGNES_API_KEY environment variable.

Python (OpenAI SDK)

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AGNES_API_KEY"],
    base_url="https://apihub.agnes-ai.com/v1",
)

# Text-to-Image
resp = client.images.generate(
    model="agnes-image-2.1-flash",
    prompt="A cute cat playing soccer on a green field, sunny day, cinematic style",
    size="1024x1024",
)
print(resp.data[0].url)

cURL (Text-to-Image)

curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer $AGNES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "A futuristic city at sunrise, cinematic realism",
    "size": "1024x768",
    "extra_body": {"response_format": "url"}
  }'

cURL (Image-to-Image)

curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer $AGNES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "Turn the scene into a rainy cyberpunk night with neon lights",
    "size": "1024x768",
    "extra_body": {
      "image": ["https://example.com/input.png"],
      "response_format": "url"
    }
  }'

Endpoint

Item Value
Method POST
URL https://apihub.agnes-ai.com/v1/images/generations
Content-Type application/json
Auth Header Authorization: Bearer <key>

Request Parameters

Parameter Type Required Description
model string Yes agnes-image-2.1-flash
prompt string Yes Image description / edit instruction
size string Yes Output size, e.g. 1024x768, 1024x1024
image string[] For img2img Input image URLs or Data URIs
return_base64 boolean No Return base64 instead of URL
extra_body object No Extra parameters (see below)
extra_body.response_format string No url (default) or b64_json
extra_body.image string[] For img2img Alternative way to pass input images

Response Format

{
  "created": 1780000000,
  "data": [
    {
      "url": "https://storage.googleapis.com/agnes-aigc/xxx.png",
      "b64_json": null,
      "revised_prompt": null
    }
  ]
}

Access the image at data[0].url. For base64 output, use data[0].b64_json.

Capabilities

1. Text-to-Image (文生图)

Generate an image from a text description. Use detailed prompts with:

[主体] + [场景/环境] + [风格] + [光线] + [构图] + [质量要求]

Example: A futuristic city marketplace, flying vehicles, holographic signs, dense crowds, neon lighting, cinematic realism, ultra-detailed

2. Image-to-Image (图生图)

Edit an existing image while preserving its structure. Provide the input image URL via extra_body.image:

edit = client.images.generate(
    model="agnes-image-2.1-flash",
    prompt="Keep the cat and soccer ball, change scene to snowy winter field",
    size="1024x1024",
    extra_body={"image": ["https://example.com/original.png"]},
)

3. Base64 Output

For programmatic processing without downloading from URL:

resp = client.images.generate(
    model="agnes-image-2.1-flash",
    prompt="A simple red circle on white background",
    size="512x512",
    return_base64=True,
)
b64_data = resp.data[0].b64_json

Important Notes

  • response_format must be placed inside extra_body, NOT at the top level
  • Image generation may take 10-60 seconds; set client timeout to 60-360s
  • Input images for img2img must be publicly accessible HTTPS URLs or Data URIs
  • Do NOT add tags: ["img2img"] — just provide the image array
  • Both agnes-image-2.1-flash (text-to-image) and agnes-image-2.0-flash (image-to-image focused) are available; 2.1 handles both tasks

Bundled Scripts

scripts/generate.py

Generate images from the command line:

# Text-to-image
python scripts/generate.py --prompt "A dragon flying over mountains" --size 1024x768

# Image-to-image
python scripts/generate.py --prompt "Make it nighttime" --input-image https://example.com/photo.png

# Save to file
python scripts/generate.py --prompt "Sunset beach" --output sunset.png

Reads AGNES_API_KEY from environment.

Reference

See references/api_reference.md for complete parameter details, error handling, prompt engineering tips, and more examples.