Generate Images
Creates an image given a prompt. Learn more.
Authorization
Bearer
In: header
Request Body
application/json
模型名称。若需异步方式生成(推荐用于耗时较长的任务),请使用 POST /v2/image-tasks,入参格式与本接口完全一致。
gpt-image-2
| 模型 ID | 说明 |
|---|---|
gpt-image-2 | OpenAI GPT Image 2 |
豆包 Seedream 系列
| 模型 ID | 说明 |
|---|---|
doubao-seedream-3-0-t2i-250415 | Seedream 3.0 |
doubao-seedream-4-5-t2i-250505 | Seedream 4.5 |
doubao-seedream-4-5-251128 | Seedream 4.5(增强版) |
doubao-seedream-5-0-t2i-250804 | Seedream 5.0 |
Gemini 系列
| 模型 ID | 系列名 | 说明 |
|---|---|---|
gemini-2.5-flash-image | Nano Banana | Gemini 2.5 Flash Image |
gemini-3-pro-image | Nano Banana Pro | Gemini 3 Pro Image |
gemini-3.1-flash-image | Nano Banana 2 | Gemini 3.1 Flash Image |
Kling 系列
| 模型 ID | 说明 |
|---|---|
kling-image-2.1 | Kling Image 2.1 |
kling-image-3.0 | Kling Image 3.0 |
kling-image-3.0-omni | Kling Image 3.0 Omni,支持 auto 宽高比 |
kling-image-o1 | Kling Image O1,支持 auto 宽高比 |
kling-image-scene | Kling Image Scene,扩图模式,需配合 extra_fields.scene_type="image_expand" |
Vidu 系列
| 模型 ID | 说明 |
|---|---|
vidu-image-q2 | Vidu Q2 |
Qwen 系列
| 模型 ID | 说明 |
|---|---|
qwen-image-0925 | Qwen-Image-0925,通过 size 传自定义像素尺寸 |
Hunyuan 系列
| 模型 ID | 说明 |
|---|---|
hunyuan-image-3.0 | Hunyuan 3.0,通过 size 传自定义像素尺寸;支持全景图模式 |
所需图像的文本描述。gpt-image-1 的最大长度为 32000 个字符,dall-e-2 的最大长度为 1000 个字符,dall-e-3 的最大长度为 4000 个字符。豆包 Seedream 系列建议不超过 300 汉字或 600 英文单词。
图生图 / 多图融合的输入图片,支持图片 URL 或 Base64 编码字符串。单张传字符串,多张传字符串数组(最多 14 张,视模型而定)。
豆包 Seedream 系列图片输入限制:
- 支持格式:jpeg、png、webp、bmp、tiff、gif、heic、heif
- 宽高比(宽/高)范围:[1/16, 16]
- 宽高长度(px)> 14
- 大小:不超过 30MB
- 总像素:不超过 36000000px(6000x6000)
- Seedream 5.0 pro 最多支持传入 10 张参考图;Seedream 5.0 lite / 4.5 / 4.0 最多支持传入 14 张参考图。
各模型参考图数量上限(超出将被自动截断):
| 模型 | 最多参考图数 |
|---|---|
gemini-2.5-flash-image | 3 张 |
gemini-3-pro-image | 14 张 |
gemini-3.1-flash-image | 14 张 |
kling-image-2.1 | 4 张 |
kling-image-3.0 | 1 张 |
kling-image-3.0-omni | 10 张 |
kling-image-o1 | 10 张 |
kling-image-scene | 1 张(扩图原图) |
vidu-image-q2 | 7 张 |
qwen-image-0925 | 1 张 |
hunyuan-image-3.0 | 3 张 |
超出上限的图片将被自动截断,请勿超量传入。
生成图像数量。默认 1。
豆包 Seedream 系列:n 映射为组图生成的 max_images(最多允许生成的张数上限),模型以 auto 模式根据 prompt 自主推理实际生成张数,最终张数 ≤ n。如需精确控制张数,建议在 prompt 中明确描述(如「生成 4 张不同风格的图片」)。支持范围 1-15。
Kling 系列:支持 1-9 张,超出自动截断。
OG(gpt-image-2):支持 1-8 张,超出自动截断。
其他模型(Gemini / Vidu / Qwen / Hunyuan 等):底层 API 不支持数量参数,n 字段传入后会被忽略,固定返回 1 张。
图像尺寸。
gpt-image-2:指定 宽x高,总像素数范围 655,360 – 8,294,400。
Gemini(GG)系列:映射到宽高比(AspectRatio),不支持自定义像素尺寸。 支持两种传入方式:
- 直接传宽高比字符串(推荐),如
"1:1"、"16:9"、"9:16" - 传像素尺寸字符串,系统自动查表或计算最近邻宽高比,如
"1024x1024"→"1:1"
各版本支持的宽高比:
| 宽高比 | gemini-2.5-flash-image | gemini-3-pro-image | gemini-3.1-flash-image |
|---|---|---|---|
| 1:1 | ✅ | ✅ | ✅ |
| 2:3 / 3:2 | ✅ | ✅ | ✅ |
| 3:4 / 4:3 | ✅ | ✅ | ✅ |
| 4:5 / 5:4 | ✅ | ✅ | ✅ |
| 9:16 / 16:9 | ✅ | ✅ | ✅ |
| 21:9 | ✅ | ✅ | ✅ |
| 1:4 / 4:1 | ❌ | ❌ | ✅ |
| 1:8 / 8:1 | ❌ | ❌ | ✅ |
默认值 "1:1"。传入不支持的宽高比时系统将回退到 "1:1" 并记录日志。
Kling 系列(kling-image-2.1 / 3.0 / 3.0-omni / o1):映射到宽高比(AspectRatio)。
支持直接传宽高比字符串或像素尺寸(自动取最近邻)。
| 宽高比 | 2.1 / 3.0 | 3.0-Omni / O1 |
|---|---|---|
| 1:1 | ✅ | ✅ |
| 2:3 / 3:2 | ✅ | ✅ |
| 3:4 / 4:3 | ✅ | ✅ |
| 9:16 / 16:9 | ✅ | ✅ |
| 21:9 | ✅ | ✅ |
auto | ❌ | ✅(模型自动选择) |
kling-image-scene 为扩图模式,size 参数无效,输出尺寸由扩图参数决定。
Vidu(vidu-image-q2):映射到宽高比(AspectRatio)。
支持:1:1、2:3、3:2、3:4、4:3、9:16、16:9、21:9。默认 "1:1"。
Qwen(qwen-image-0925):指定 宽x高 自定义像素尺寸,总像素范围 261,632 – 4,194,304(即 512×512 至 2048×2048)。不支持宽高比格式。
Hunyuan(hunyuan-image-3.0):指定 宽x高 自定义像素尺寸,宽高均在 [512, 2048] 范围内,且宽×高 ≤ 1,048,576(即 1024×1024)。不支持宽高比格式。
豆包 Seedream 系列:支持两种方式(不可混用):
方式一:分辨率档位标签(模型自动选择最佳宽高比)
| 档位 | doubao-seedream-3-0-* | doubao-seedream-4-5-* | doubao-seedream-5-0-* |
|---|---|---|---|
1K | ✅ | ❌ | ✅(仅 pro) |
2K | ❌ | ✅ | ✅ |
3K | ❌ | ❌ | ✅(仅 lite) |
4K | ❌ | ✅ | ✅(仅 lite) |
方式二:指定宽×高像素值
默认值 2048x2048(Seedream 3.0 默认 1024x1024)。常用推荐值:
| 档位 | 1:1 | 16:9 | 9:16 | 4:3 | 3:4 |
|---|---|---|---|---|---|
| 2K | 2048x2048 | 2560x1440 | 1440x2560 | 2304x1728 | 1728x2304 |
| 4K | 4096x4096 | 5504x3040 | 3040x5504 | 4704x3520 | 3520x4704 |
Seedream 总像素范围:[3,686,400 – 16,777,216](最小约 2560×1440),宽高比范围 [1/16, 16]。
返回格式。url(默认,返回图片下载链接,24小时有效)或 b64_json(返回 Base64 编码字符串)。
是否在生成的图片上添加水印。豆包 Seedream 系列支持,默认 false。
允许为生成的图像的背景设置透明度。此参数仅支持 gpt-image-1。必须是以下之一 透明、不透明或自动(默认值)。使用自动时,模型将自动确定图像的最佳背景。
如果是透明的,则输出格式需要支持透明度,因此应将其设置为 png(默认值)或 webp。
控制 gpt-image-1 生成的图像的内容审核级别。必须为低, 以进行限制较少的筛选或自动(默认值)。
图像质量 / 分辨率档位。各模型语义不同:
Gemini(GG)系列:映射到分辨率档位(Resolution)。
- 直接传档位(推荐):
1K、2K、4K;gemini-3.1-flash-image额外支持720P - 兼容标准 quality 值:
low/standard→1K,medium/hd/high→2K - 默认值:
1K
gpt-image-2:映射到图片精度档位。
low/standard→ image2_low(最低精度)medium→ image2_mediumhd/high→ image2_high(最高精度)- 默认值:
standard(image2_low)
Kling 系列(除 scene):映射到分辨率档位(注意:使用小写)。
- 直接传档位(推荐):
1k、2k;kling-image-3.0-omni/kling-image-o1额外支持4k - 兼容标准 quality 值:
low/standard/medium→1k,hd/high→2k - 默认值:
1k kling-image-scene(扩图模式)忽略此参数
Vidu(vidu-image-q2):映射到分辨率档位。
- 直接传档位(推荐):
1080p、2K、4K - 兼容标准 quality 值:
low/standard→1080p,medium/hd/high→2K - 默认值:
1080p
Qwen(qwen-image-0925)/ Hunyuan(hunyuan-image-3.0):不使用此参数(通过 size 传像素尺寸)。
其他模型:low、medium、standard、hd / high。默认 standard。
输出图像文件格式。不传时跟随模型默认值。
gpt-image-2 / Kling 系列:支持 jpeg / png。
豆包 Seedream 系列:支持 jpeg / png / webp;仅 doubao-seedream-5-0 系列支持。
其他模型:不支持,传入后忽略。
输出图像的压缩质量(0-100),仅在 output_format 为 jpeg 或 webp 时有效。
模型扩展参数,不支持的字段将被忽略。
| 参数 | 类型 | 支持模型 | 说明 |
|---|---|---|---|
guidance_scale | number | 豆包 Seedream 系列 | 引导强度,推荐取值范围 1-5 |
negative_prompt | string | gpt-image-2、Gemini 系列、Kling 系列 | 反向提示词 |
seed | integer | gpt-image-2、Gemini 系列、Kling 系列 | 随机种子,控制生成结果可复现性 |
enhance_prompt | string | Gemini 系列 | 自动优化 prompt,取值 Enabled / Disabled |
scene_type | string | Kling scene、Hunyuan 3.0 | 场景类型:image_expand(Kling 扩图)/ 3d_panorama(Hunyuan 全景图) |
expansion | object | kling-image-scene | 扩图比例,配合 scene_type="image_expand" 使用,含 up / down / left / right 四个方向,取值范围 [0, 2],新图面积不超过原图 3 倍 |
Response Body
application/json
curl -X POST "https://loading/v1/images/generations/" \ -H "Content-Type: application/json" \ -d '{ "prompt": "string" }'{
"created": 0,
"data": [
{
"b64_json": "string",
"url": "string"
}
],
"usage": {
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": {
"text_tokens": 0,
"image_tokens": 0
}
}
}Last updated on