You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ai-image/docs/agnes-ai-doc.md

493 KiB

<html lang="zh-Hans" class="inter_1d81deff-module__CYM0aG__variable papermono_89c757f2-module__6aS5zq__variable dark" data-banner-state="visible" data-assistant-state="closed" data-page-mode="none" data-current-path="/"><head></head>
Skip to main content
Search...
⌘K
搜索...
Navigation
图像
Agnes Image 2.1 Flash

开始使用

使用指南

图像

Agnes Image 2.1 Flash

复制页面

升级版图像生成模型,优化高信息密度图像生成,并支持文生图、图生图和多图合成工作流。

复制页面
Agnes Image 2.1 Flash 是 Agnes AI 的升级图像生成模型,支持文生图、图生图和多图合成。相比 2.0 版本,它更适合高信息密度图像、复杂构图和细节丰富的视觉场景。

模型名称

agnes-image-2.1-flash

API Endpoint

POST /v1/images/generations

核心优化

高信息密度图像、复杂视觉细节和语义对齐。

当前价格

生成图像当前为 $0 / 张

概述

Agnes Image 2.1 Flash 可根据文本提示词生成图像,也可基于输入图像进行转换、重绘和风格化编辑。它支持以图像 URL 或 Base64 数据形式返回结果。

高信息密度优化

更适合复杂场景、丰富构图和多层视觉元素。

构图保留

图生图编辑时可尽量保留原始构图和主体布局。

核心能力

文生图

根据自然语言提示词生成高质量图像。

图生图

根据提示词转换或优化现有图像。

多图合成

使用多张参考图像组合生成新图像。

高信息密度图像

优化细节丰富、布局复杂、视觉元素密集的图像生成效果。

构图保留

编辑输入图像时保留原始构图和主体布局。

灵活尺寸控制

使用 1K2K3K4K 等尺寸档位,并配合支持的宽高比。

URL / Base64 输出

支持图像 URL 或 Base64 数据返回。

适用场景

创意设计

概念艺术、视觉探索和海报草稿。

营销内容

活动图片、产品视觉和社交媒体创意。

高密度视觉生成

精细场景、复杂环境和丰富构图。

图像转换

风格迁移、场景重打光和背景变换。

产品可视化

产品照片、模型图和商业视觉。

社交媒体素材

封面、横幅、缩略图和帖子图片。

API Reference

Endpoint

POST https://apihub.agnes-ai.com/v1/images/generations

请求头

-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"

请求参数

参数类型必填说明
modelstring模型名称,使用 agnes-image-2.1-flash
promptstring图像生成或图像编辑的文本指令。
sizestring输出尺寸档位。推荐值为 1K2K3K4K。也兼容 1024x768 这类历史精确尺寸写法,但不支持的尺寸可能会被标准化。
ratiostring与档位式 size 配合使用的宽高比。支持 1:13:44:316:99:162:33:221:9,默认值为 1:1
imagestring[]图生图或多图合成必填输入图像数组,支持公共图像 URL 或 Data URI Base64。多图合成时传入多张图像。
return_base64boolean文生图需要以 Base64 返回时使用。
extra_bodyobject高级工作流的附加参数。
extra_body.response_formatstring输出格式,常见值为 urlb64_json

尺寸与宽高比

为了获得可预期的输出尺寸,建议将 sizeratio 配合使用。
  • 推荐 size 值:1K2K3K4K
  • 支持的 ratio 值:1:13:44:316:99:162:33:221:9
  • 如果请求 1920x10802560x1440 这类不受原生支持的精确尺寸,服务可能会自动映射到最接近的标准档位和宽高比。
  • 如果需要生成 1920x10802560x1440 这类常见 16:9 显示素材,建议请求 size: "2K"ratio: "16:9",再在下游裁剪或缩放到最终画布。
1920x10802560x1440 是标准显示器分辨率,但不是该图像模型的原生输出尺寸。不支持的精确尺寸可能会被标准化,例如映射为 16:9 的 1K 输出尺寸 1312x736

输出尺寸参考

Ratio1K2K3K4K
1:11024x10242048x20483072x30724096x4096
3:4864x11521728x23042592x34563456x4608
4:31152x8642304x17283456x25924608x3456
16:91312x7362624x14723936x22085248x2944
9:16736x13121472x26242208x39362944x5248
2:3832x12481664x24962496x37443328x4992
3:21248x8322496x16643744x24964992x3328
21:91568x6723136x13444704x20166272x2688

示例:16:9 的 2K 输出

curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "A cinematic product hero image for a desktop monitor wallpaper, clean lighting, high detail",
    "size": "2K",
    "ratio": "16:9",
    "extra_body": {
      "response_format": "url"
    }
  }'
该请求会返回 16:9 的 2K 档位输出尺寸:2624x1472

重要说明

请勿在请求体顶层放置 response_format。需要 URL 输出时,请使用 extra_body.response_format: "url";图生图 Base64 输出请使用 extra_body.response_format: "b64_json"

文生图

必填参数为 modelpromptsize

尺寸 + 宽高比

使用 2K 等档位式 size,并配合 16:9ratio

图生图

需要在 extra_body.image 中提供输入图像 URL 或 Data URI Base64。

多图合成

extra_body.image 中传入多张参考图像。

Base64 输出

文生图可使用 return_base64: true;图生图请使用 extra_body.response_format: "b64_json"

无需 tags

图生图不需要传递 tags: ["img2img"]

请求示例

  • 文生图:URL 输出
  • 文生图:Base64 输出
  • 图生图:URL 输出
  • 图生图:Base64 输出
  • 多图合成
  • Data URI 输入
curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "A luminous floating city above a misty canyon at sunrise, cinematic realism",
    "size": "1024x768",
    "extra_body": {
      "response_format": "url"
    }
  }'
返回路径:data[0].url
curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "A clean product photo of a glass cube on a white studio background, soft shadows, high detail",
    "size": "1024x768",
    "return_base64": true
  }'
返回路径:data[0].b64_json
curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "Transform the scene into a rain-soaked cyberpunk night with neon reflections while preserving the original composition",
    "size": "1024x768",
    "extra_body": {
      "image": [
        "https://example.com/input-image.png"
      ],
      "response_format": "url"
    }
  }'
返回路径:data[0].url
curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "Make the object orange while preserving the original composition",
    "size": "1024x768",
    "extra_body": {
      "image": [
        "https://example.com/input-image.png"
      ],
      "response_format": "b64_json"
    }
  }'
返回路径:data[0].b64_json
curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "Combine the two characters into an intense fantasy battle scene, dynamic lighting, detailed background, cinematic composition",
    "size": "1024x768",
    "extra_body": {
      "image": [
        "https://example.com/character-1.png",
        "https://example.com/character-2.png"
      ],
      "response_format": "url"
    }
  }'
data:image/png;base64,BASE64_HERE
curl https://apihub.agnes-ai.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-image-2.1-flash",
    "prompt": "Make the object matte black while preserving the original composition",
    "size": "1024x768",
    "extra_body": {
      "image": [
        "data:image/png;base64,BASE64_HERE"
      ],
      "response_format": "b64_json"
    }
  }'

响应格式

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

推荐提示词结构

文生图结构

[主体] + [场景 / 环境] + [风格] + [光照] + [构图] + [质量要求]
日出时分薄雾峡谷上方的发光浮空城市,电影级写实风格,广角构图,丰富的建筑细节,柔和的金色光线,高视觉密度

图生图结构

[改变要求] + [新风格 / 场景] + [需要添加或移除的元素] + [需要保留的元素]
将白天街道场景改为电影级赛博朋克夜景,添加霓虹招牌和湿滑路面倒影,同时保留原始街道布局、相机角度和主要建筑形状。

多图合成结构

请说明每张参考图的角色,以及最终图像应如何组合这些参考信息。
[参考图角色] + [目标场景] + [图像之间的关系] + [风格 / 光照 / 构图]
将第一张图作为主要角色,第二张图作为产品参考,生成一张电影级活动海报,保留角色身份和产品外形,使用自然光照和干净的商业构图。

高信息密度图像

请清晰描述视觉层次结构,包括主要主体、背景环境、重要次要细节、风格、光照和构图约束。
建在悬崖上的大型奇幻港口城市,数百艘小船,层叠的石桥,发光的窗户,远山,多云的日落天空,电影级奇幻写实风格,广角构图,丰富的建筑细节,高视觉密度

常见错误与故障排除

顶层放置 response_format

错误写法:
{
  "model": "agnes-image-2.1-flash",
  "prompt": "A futuristic city",
  "size": "1024x768",
  "response_format": "url"
}
正确写法:
{
  "model": "agnes-image-2.1-flash",
  "prompt": "A futuristic city",
  "size": "1024x768",
  "extra_body": {
    "response_format": "url"
  }
}

图生图传递 tags

图生图不需要传递 tags: ["img2img"]。只需在 extra_body.image 中提供输入图像。

输入图像 URL 无法访问

请使用公共 HTTPS 图像 URL,并确认不需要登录、cookie 或私有请求头;如果无法公开访问,请使用 Data URI Base64。

请求超时

根据提示词复杂度、图像尺寸和服务器负载情况,图像生成可能需要数秒到几十秒。客户端超时时间建议设置为 60s - 360s

图生图缺少 image 参数

图生图和多图合成生成时,extra_body.image 为必填项。
{
  "model": "agnes-image-2.1-flash",
  "prompt": "Make the image cyberpunk style while preserving the original composition",
  "size": "1024x768",
  "extra_body": {
    "image": ["https://example.com/input.png"],
    "response_format": "url"
  }
}

定价

类型标准价格当前价格
生成图像$0.003 / 张$0 / 张

接入检查清单

使用 agnes-image-2.1-flash 作为模型名称。
使用 https://apihub.agnes-ai.com/v1/images/generations 作为 API 端点。
文生图请求必须包含 modelpromptsize
为获得可预期的输出尺寸,建议使用 1K2Ksize 档位,并配合 ratio
图生图和多图合成请求需要在 extra_body.image 中提供输入图像。
请勿将 response_format 放在顶层,也不要传递 tags: ["img2img"]
Agnes Image 2.0 Flash
Agnes Video V2.0
</html>