跳到主要内容

图像生成

需要 image scope。两种模式:同步出图(Seedream 系列)与异步任务(即梦系列)。计费按张;异步任务按成功取回的张数计费,提交本身不扣费。

POST /v1/images/generations(同步)

curl https://ai-gateway-6a41e6.preview.tencent-zeabur.cn/v1/images/generations \
-H "Authorization: Bearer agw_你的key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-260128",
"prompt": "一张简洁的白底产品图,蓝色玻璃水杯,摄影棚光线",
"size": "1024x1024",
"response_format": "url",
"user": "user-1234"
}'

响应:

{
"created": 1751856000,
"data": [{ "url": "https://..." }]
}
  • response_format: url(默认,链接有时效)或 b64_json
  • n 支持多张,按张计费。

POST /v1/images/tasks(异步提交)

适用于耗时较长的模型(即梦):

curl https://ai-gateway-6a41e6.preview.tencent-zeabur.cn/v1/images/tasks \
-H "Authorization: Bearer agw_你的key" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng-t2i-v40",
"prompt": "赛博朋克城市夜景,霓虹灯,雨后街道",
"size": "1024x1024",
"user": "user-1234"
}'

响应返回任务 ID:

{ "id": "task_...", "status": "pending" }

GET /v1/images/tasks/{task_id}(轮询取回)

curl https://ai-gateway-6a41e6.preview.tencent-zeabur.cn/v1/images/tasks/task_xxx \
-H "Authorization: Bearer agw_你的key"

status 流转:pendingrunningsucceeded / failed。首次以 succeeded 取回时结算费用;failed 不计费;未轮询取回不扣费。任务结果有缓存,重复轮询不会重复计费。