GPT Image 2· 文生图
https://api.sozdai.ai/v1/media/generations#提交任务
媒体生成是异步的:提交后立即返回任务 id,不阻塞等待。
curl https://api.sozdai.ai/v1/media/generations \
-H "Authorization: Bearer $CORRY_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "gpt-image-2", "prompt": "a cute robot mascot, flat vector logo" }'
# → { "id": "cmus7q0x9000108l3f5g2abcd", "status": "queued" }#请求参数
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
prompt | string | 是 | — | 描述要生成图片的提示词(最多 20000 字符)。 |
aspect_ratio | string | 否 | auto | 输出图片的宽高比。注意:5:4 和 4:5 仅支持 1K。 可选值: auto, 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16, 2:1, 1:2, 3:1, 1:3, 21:9, 9:21, 5:4, 4:5 |
resolution | string | 否 | 1K | 输出图片的分辨率;分辨率越高价格越高(2K ≈ 1K 的 2 倍,4K ≈ 4 倍),具体见价目表。注意:1:1 无法转 4K;宽高比为 auto 时只能出 1K。 可选值: 1K, 2K, 4K |
callback_url | string | 否 | — | 可选的公网 http(s) 地址。任务生成完成(成功或失败)后,我们会第一时间把结果 POST 到这里。 |
#查询任务结果
生成是异步的 —— 提交接口会立即返回一个任务 id。用这个 id 每隔几秒请求下面的接口,直到 status 变为 succeeded(结果就绪)或终止状态(failed / timeout)。
https://api.sozdai.ai/v1/media/generations/{id}# take the id from the submit response, then poll every ~3s
curl https://api.sozdai.ai/v1/media/generations/cmus7q0x9000108l3f5g2abcd \
-H "Authorization: Bearer $CORRY_KEY"
# repeat until "status" is "succeeded" (or "failed" / "timeout")#响应示例
提交时
{
"id": "cmus7q0x9000108l3f5g2abcd",
"status": "queued",
"type": "image",
"model": "gpt-image-2"
}成功后(轮询返回)
{
"id": "cmus7q0x9000108l3f5g2abcd",
"status": "succeeded",
"type": "image",
"model": "gpt-image-2",
"result": { "urls": ["https://cdn.sozdai.ai/image/1782537315223-b49c0c1b771f.png"] },
"cost": "0.0500",
"currency": "USD"
}响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
status | string | 任务状态:queued / submitted / succeeded / failed / timeout。 |
type | string | 媒体类型:image / video / music。 |
model | string | 你请求的模型名。 |
result | object | 成功时存在,result.urls 为永久文件 URL 数组。 |
error | string | 任务失败时的错误信息。 |
cost | string | 本次任务扣费金额 —— 美元字符串(如 "0.1200"),配合 currency 字段。 |
currency | string | cost 的货币,恒为 "USD"。 |


