创建异步图片任务

POST/v1/async/images/tasks

创建持久化的异步图片生成任务。接口立即返回 HTTP 202;使用查询异步图片任务轮询结果。

同步接口 POST /v1/images/generations 保持不变。完整流程见异步图片生成。

身份验证

Authorization Bearer

在 Authorization header 中使用 API key 作为 Bearer token。

Headers

Idempotency-Keystring

推荐的重试 key,按已认证所有者隔离,最长 200 个字符。

Request Body

modelstringrequired

对外图片模型名。

promptstring

图片提示词,具体要求由所选模型决定。

executionenum<string>

执行偏好。

ninteger

图片数量。

sizestring

请求的图片尺寸,例如 1024x1024。

qualitystring

模型支持时指定图片质量。

output_formatstring

模型支持时指定输出格式。

streamboolean

必须为 false 或省略。

partial_imagesinteger

不支持,请省略。

还可以传入同步图片接口接受的其他模型专属字段。

Response

idstring

以 img_task_ 开头的任务 ID。

objectstring

image_generation.task

modelstring

对外模型名。

statusstring

初始状态,通常为 queued。

executionenum<string>

调度前为请求偏好,选路后为实际执行模式。

versioninteger

单调递增的任务版本。

resultobject

幂等重放返回已完成任务时的图片响应。

errorobject

幂等重放返回 failed 或 needs_attention 任务时的错误详情。

error.messagestring

Human-readable error message.

error.codestring

Machine-readable error code.

error.typestring

Error category when returned.

error.stagestring

Processing stage where the error occurred.

error.upstream_http_statusinteger

Provider HTTP status when the error came from upstream.

error.upstream_messagestring

Provider error message when available.

created_atstring

ISO-8601 创建时间。

updated_atstring

ISO-8601 最近更新时间。

completed_atstring

任务进入终态时的 ISO-8601 完成时间。

请求

Shell
1curl -X POST https://api.token360.ai/v1/async/images/tasks \
2  -H "Authorization: Bearer sk-your-api-key" \
3  -H "Content-Type: application/json" \
4  -H "Idempotency-Key: image-order-20260921-0001" \
5  -d '{
6    "model": "gpt-image-2.5-flare",
7    "prompt": "日出时的水彩灯塔",
8    "size": "1024x1024",
9    "execution": "auto"
10  }'

响应

JSON
1{
2  "id": "img_task_01abc",
3  "object": "image_generation.task",
4  "model": "gpt-image-2.5-flare",
5  "status": "queued",
6  "execution": "auto",
7  "version": 1,
8  "created_at": "2026-09-21T12:00:00Z",
9  "updated_at": "2026-09-21T12:00:00Z"
10}
此页面对您有帮助吗?
创建异步图片任务 · Token360