本文档由 云音工坊 自动生成,如有疑问,请联系客服微信:yuntts !
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /api/v1/yunimg/images/generations | 创建异步生成任务 |
| GET | /api/v1/yunimg/images/generations/{task_id} | 查询任务状态与结果 |
| POST | /api/v1/yunimg/uploads/images | 上传参考图换取 URL(multipart,不计费) |
https://你的域名/api/v1(注意不是 wp-json)。Authorization: Bearer <你的 API Key>。| 模型 | 说明 |
|---|---|
gpt-image-2.6-flare-official | 快速出图 |
gpt-image-2.6-sunburst-official | 精细编辑 |
-official 后缀);gpt-image-2.6-official 只是系列名,不能作为 model 传参。| 参数 | 类型 | 必填 | 默认 | 取值 / 约束 |
|---|---|---|---|---|
model | string | 是 | — | 见上表,二选一 |
prompt | string | 是 | — | 1~32000 字符 |
size | string | 否 | auto | auto、比例名(1:1、3:2、2:3、4:3、3:4、5:4、4:5、16:9、9:16、2:1、1:2、21:9、9:21、3:1、1:3)或像素尺寸(如 1024x1024、1536x1024) |
resolution | string | 否 | 1k | 1k / 2k / 4k;显式传入时优先于按 size 推断 |
quality | string | 否 | medium | auto / low / medium / high / xhigh / max |
n | integer | 否 | 1 | 1~4;output_format=svg 时只能为 1 |
output_format | string | 否 | 不传(默认 png) | png / jpeg / webp / gif / svg |
output_compression | integer | 否 | — | 0~100,仅 jpeg / webp 有效 |
frame_count | integer | 否 | — | GIF 帧数,2~16(仅 output_format=gif) |
frame_duration_ms | integer | 否 | — | GIF 每帧时长(毫秒,仅 output_format=gif) |
svg | object | 否 | — | SVG 输出必填,格式 {"model":"gpt-5"}(仅 output_format=svg) |
background | string | 否 | 不传 | auto / transparent / opaque;transparent 仅 png / webp |
moderation | string | 否 | 不传 | auto / low |
complexity | string | 否 | high | low / medium / high(不单独收费) |
image_urls | string[] | 否 | — | 参考图 URL,最多 16 张,须 http/https 且服务端可访问 |
mask_url | string | 否 | — | PNG alpha 遮罩,需配合 image_urls,尺寸同首张参考图;与 markup_url / markup 互斥 |
markup_url | string | 否 | — | 带标注的参考图,需配合 image_urls;与 mask_url 互斥 |
markup | object | 否 | — | 内联标注对象;与 mask_url 互斥 |
client_business_id | string | 否 | — | 客户侧业务 ID,≤150 字符,可按它查询任务 |
callback_url | string | 否 | — | HTTPS 回调地址,需账号已开通任务回调 |
response_format | string | 否 | url | 兼容参数,仅支持 url,不参与实际请求 |
| 能力 | 约束 | 违反时 |
|---|---|---|
像素尺寸 size | 宽高均为 16 的倍数;最长边 ≤ 3840;总像素 655,360 ~ 8,294,400 | 返回 400 并提示具体原因 |
任意比例 宽:高 | 宽高比 ≤ 3:1 | 返回 400 |
| GIF 输出 | 仅文生图;不能用 image_urls、mask_url、markup_url、markup、output_compression;frame_count 2~16 | 返回 400 |
| SVG 输出 | 仅文生图;n 只能为 1;必须传 svg.model;不能用参考图 / 遮罩 / 标注 / 压缩 | 返回 400 |
| 透明背景 | background=transparent 仅支持 png / webp 输出;SVG 默认透明,不要传 | 返回 400 |
| 遮罩 / 标注 | 都必须配合 image_urls;mask_url 与 markup_url / markup 互斥 | 返回 400 |
| 压缩 | output_compression 仅 jpeg / webp 有效 | 返回 400 |
{
"id": "tsk_img_01M6P187GE337D4ZABB39Q2HYC",
"object": "generation.task",
"model": "gpt-image-2.6-flare-official",
"status": "queued",
"progress": 0,
"created_at": 1793888361,
"completed_at": 0,
"expires_at": 0
}{
"model": "gpt-image-2.6-sunburst-official",
"prompt": "Keep the subject and replace the background with a snowy forest",
"image_urls": ["https://example.com/reference.png"],
"size": "16:9",
"resolution": "2k",
"quality": "high",
"n": 1
}{
"model": "gpt-image-2.6-sunburst-official",
"prompt": "Keep the subject and replace the masked area with a snowy forest",
"image_urls": ["https://example.com/reference.png"],
"mask_url": "https://example.com/mask.png",
"quality": "high",
"n": 1
}{
"model": "gpt-image-2.6-sunburst-official",
"prompt": "Follow the markup annotations to adjust the layout",
"image_urls": ["https://example.com/reference.png"],
"markup_url": "https://example.com/markup.png",
"quality": "high",
"n": 1
}{
"model": "gpt-image-2.6-flare-official",
"prompt": "Four variations of a minimalist mountain logo",
"size": "1:1",
"resolution": "1k",
"quality": "medium",
"n": 4,
"output_format": "webp",
"output_compression": 80,
"background": "transparent",
"complexity": "high",
"moderation": "auto"
}{
"success": true,
"message": "",
"data": {
"id": "upload_abc12345",
"url": "https://files.example.com/uploads/123/1737568800_abc12345.png",
"mime_type": "image/png",
"size": 89234
}
}{
"model": "gpt-image-2.6-flare-official",
"prompt": "A paper airplane looping across a blue sky, flat illustration",
"output_format": "gif",
"frame_count": 8,
"frame_duration_ms": 200,
"size": "1:1",
"n": 1
}{
"model": "gpt-image-2.6-flare-official",
"prompt": "A minimalist mountain logo, flat vector style",
"output_format": "svg",
"svg": { "model": "gpt-5" },
"n": 1
}{
"model": "gpt-image-2.6-sunburst-official",
"prompt": "A wide product banner, soft studio lighting",
"size": "1536x1024",
"quality": "high",
"n": 1
}task_id 支持三种:任务 ID(tsk_img_*)、本站订单内任务号(taimg_*)、创建时传入的 client_business_id。只能查询自己的任务。{
"id": "tsk_img_01M6P187GE337D4ZABB39Q2HYC",
"object": "generation.task",
"model": "gpt-image-2.6-flare-official",
"status": "in_progress",
"progress": 10,
"created_at": 1793888361,
"charge": 0.2499
}{
"id": "tsk_img_01M6P187GE337D4ZABB39Q2HYC",
"client_business_id": "order_20261105_001",
"object": "generation.task",
"model": "gpt-image-2.6-flare-official",
"status": "completed",
"progress": 100,
"created_at": 1793888361,
"finished_at": 1793888380,
"completed_at": 1793888380,
"expires_at": 1793974780,
"result": {
"type": "image",
"data": [
{ "url": "https://files.example.com/images/tsk_img_01M6P187GE337D4ZABB39Q2HYC/1793888377_2b8e7ee8.png" }
]
},
"usage": {
"charge_type": "per_token",
"billed_tokens": 839,
"input_tokens": 15,
"output_tokens": 824,
"total_tokens": 839,
"input_tokens_details": {
"text_tokens": 15,
"image_tokens": 0,
"cached_tokens": 0,
"cached_tokens_details": { "text_tokens": 0, "image_tokens": 0 }
},
"output_tokens_details": { "text_tokens": 0, "image_tokens": 824 }
},
"charge": 0.2499
}{
"id": "tsk_img_01M6NA2S6SDYWY1DXF10S8SGWT",
"client_business_id": "order_20261105_002",
"object": "generation.task",
"model": "gpt-image-2.6-flare-official",
"status": "failed",
"progress": 100,
"created_at": 1793864066,
"finished_at": 1793864097,
"error": {
"code": "generation_failed",
"message": "输入或生成内容未通过安全审核. 请修改输入后重试."
},
"charge": 0
}expires_at:结果图过期时间(Unix 秒),约 24 小时,请及时下载保存。usage:按 token 计费的任务在结算后返回;失败或尚未结算时不返回。charge:本接口的实际扣费金额(元)。失败或已退款为 0;未结算时为预扣金额。| 失败提示 | 含义 | 是否建议原样重试 |
|---|---|---|
| 输入或生成内容未通过安全审核. 请修改输入后重试. | 提示词或参考图触发了内容审核 | 否,需修改提示词 / 图片 |
| 输入参数无效. 请检查请求参数后重试. | 参数组合不被接受(尺寸、格式、参考图等) | 需按提示调整参数后再试 |
以上属于任务级失败,均已自动全额退款, charge为 0。
| HTTP | type | 常见 message |
|---|---|---|
| 400 | invalid_request_error | 参数校验失败(如 size 宽高必须是 16 的倍数、GIF / SVG 输出仅支持文生图) |
| 401 | authentication_error | 身份验证失败,请检查您的API密钥 |
| 402 | insufficient_quota | 余额不足,本次需要 X 元 |
| 404 | not_found_error | 任务不存在 |
| 429 | rate_limit_error | 当前提交任务数已达上限 |
| 500 | server_error | 任务创建失败 / 扣费失败 / 系统错误 |
| 503 | server_error | 线路维护中,请稍后再试 |
{
"error": {
"code": 400,
"message": "错误描述(中文,可直接展示给终端用户)",
"type": "invalid_request_error"
}
}任务生成过程中的失败不会走上面的错误结构,而是返回 status=failed+error.message(见 5.3)。