查询异步图片任务
curl --request GET \
--url https://api.yingtu.ai/v1/tasks/{task_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.yingtu.ai/v1/tasks/{task_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.yingtu.ai/v1/tasks/{task_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"task_id": "task_example",
"status": "completed",
"progress": "100%",
"model": "gpt-image-2-vip",
"action": "generate",
"created_at": 1788311383,
"started_at": 1788311384,
"completed_at": 1788311438,
"result_expires_at": 1788397838,
"result": {
"created": 1788311438,
"data": [
{
"b64_json": "iVBORw0KGgo="
}
],
"usage": {
"input_tokens": 179,
"output_tokens": 7024,
"total_tokens": 7203
}
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}统一图片任务
查询异步图片任务
查询账号隔离的任务状态,解析 Gemini 或 GPT Image 原生结果,处理结构化错误与 24 小时结果过期。
GET
/
v1
/
tasks
/
{task_id}
查询异步图片任务
curl --request GET \
--url https://api.yingtu.ai/v1/tasks/{task_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.yingtu.ai/v1/tasks/{task_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.yingtu.ai/v1/tasks/{task_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"task_id": "task_example",
"status": "completed",
"progress": "100%",
"model": "gpt-image-2-vip",
"action": "generate",
"created_at": 1788311383,
"started_at": 1788311384,
"completed_at": 1788311438,
"result_expires_at": 1788397838,
"result": {
"created": 1788311438,
"data": [
{
"b64_json": "iVBORw0KGgo="
}
],
"usage": {
"input_tokens": 179,
"output_tokens": 7024,
"total_tokens": 7203
}
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "insufficient_user_quota"
}
}任务处于
queued 或 in_progress 时继续轮询。本接口返回
Cache-Control: no-store;任务不存在与任务属于其他账号都会得到 HTTP 404。
看到 completed 后,根据 model 选择解析方式:
- Nano Banana:遍历
result.candidates[].content.parts[],查找inlineData, 再按网关根据真实字节修正后的mimeType解码data; - GPT Image:按原生 ImagesResponse 读取
result.data[].b64_json,响应不会增加 YingTu 自定义的mime_type。
result_expires_at,图片结果从完成起保留 24 小时。清理完成后,任务
状态变为 expired,同时返回 error.code=result_expired,不再携带旧 Base64。
任务失败时,用 error.code 分类,向用户展示经过处理的 error.message;只有
error.retryable=true 且仍在业务截止时间内时,才创建新的任务。
使用轮询代码
加入截止时间、Retry-After、有上限退避与分模型解析。
核对异步提交
设置幂等键,并理解多图输入和结果过期。
提交图片任务
使用正确的生成或编辑请求分支。
处理任务失败
根据结构化错误决定是否重试。
授权
YingTu API Key。
路径参数
POST /v1/images/tasks 返回的任务 ID。
响应
当前任务状态
可用选项:
gemini-2.5-flash-image, gemini-3.1-flash-lite-image, gemini-3.1-flash-image, gemini-3-pro-image, gpt-image-2-web, gpt-image-2-vip 图片任务请求的操作类型。
可用选项:
generate, edit 可用选项:
queued, in_progress, completed, failed, expired 示例:
"100%"
成功结果的过期时间,通常为完成后 24 小时,以 Unix 秒级时间戳表示。
按模型家族保留原生结果:Nano Banana 使用 GenerateContentResponse,GPT Image 使用 ImagesResponse。
- Option 1
- GPT Image 响应
Show child attributes
Show child attributes
Show child attributes
Show child attributes
最后修改于 2026年9月3日