curl -X GET https://www.geeknow.top/v1/images/generations/async/task_img_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
task_id = "task_img_abc123"
resp = requests.get(
f"https://www.geeknow.top/v1/images/generations/async/{task_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(resp.json())
const taskId = "task_img_abc123";
const response = await fetch(
`https://www.geeknow.top/v1/images/generations/async/${taskId}`,
{
method: "GET",
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
}
);
console.log(await response.json());
{
"id": "task_img_abc123",
"task_id": "task_img_abc123",
"object": "image.generation.task",
"model": "gpt-image-2-vip",
"status": "in_progress",
"progress": "10%",
"created_at": 1735689600
}
{
"data": [
{
"url": "https://geekm.oss-cn-shanghai.aliyuncs.com/image-generation-1783176295522148587.png"
}
],
"size": "1024x1024",
"usage": {
"input_tokens": 15,
"total_tokens": 211,
"output_tokens": 196,
"input_tokens_details": {
"text_tokens": 15
},
"output_tokens_details": {
"image_tokens": 196
}
}
}
{
"id": "task_img_abc123",
"task_id": "task_img_abc123",
"object": "image.generation.task",
"model": "gpt-image-2-vip",
"status": "failed",
"progress": "10%",
"created_at": 1735689600,
"error": {
"message": "Image generation failed",
"code": "generation_failed"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "Task not found",
"type": "invalid_request_error",
"param": "taskId",
"code": "task_not_found"
}
}
图像异步生成
图像异步任务查询
使用 GET /v1/images/generations/async/{taskId} 查询图像异步生成任务状态、进度和结果。
GET
https://www.geeknow.top
/
v1
/
images
/
generations
/
async
/
{taskId}
curl -X GET https://www.geeknow.top/v1/images/generations/async/task_img_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
task_id = "task_img_abc123"
resp = requests.get(
f"https://www.geeknow.top/v1/images/generations/async/{task_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(resp.json())
const taskId = "task_img_abc123";
const response = await fetch(
`https://www.geeknow.top/v1/images/generations/async/${taskId}`,
{
method: "GET",
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
}
);
console.log(await response.json());
{
"id": "task_img_abc123",
"task_id": "task_img_abc123",
"object": "image.generation.task",
"model": "gpt-image-2-vip",
"status": "in_progress",
"progress": "10%",
"created_at": 1735689600
}
{
"data": [
{
"url": "https://geekm.oss-cn-shanghai.aliyuncs.com/image-generation-1783176295522148587.png"
}
],
"size": "1024x1024",
"usage": {
"input_tokens": 15,
"total_tokens": 211,
"output_tokens": 196,
"input_tokens_details": {
"text_tokens": 15
},
"output_tokens_details": {
"image_tokens": 196
}
}
}
{
"id": "task_img_abc123",
"task_id": "task_img_abc123",
"object": "image.generation.task",
"model": "gpt-image-2-vip",
"status": "failed",
"progress": "10%",
"created_at": 1735689600,
"error": {
"message": "Image generation failed",
"code": "generation_failed"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "Task not found",
"type": "invalid_request_error",
"param": "taskId",
"code": "task_not_found"
}
}
图像异步任务查询
/v1/images/generations/async/{taskId} 用于查询图像异步生成任务。提交任务后保存返回的 id、task_id 或 taskId,再通过这个接口轮询任务状态。
- 查询路径为
GET /v1/images/generations/async/{taskId}。 - 这个接口只查询已有任务,不会重新提交生图请求。
- 任务未完成时重点读取
status和progress,其中progress在当前通道里常见为字符串百分比。 - 任务完成后返回结果对象,从
data[].url或data[].b64_json读取图片结果。 - 任务失败时读取
error.message和error.code定位原因。
方法与路径
GET /v1/images/generations/async/{taskId}
请求示例
curl -X GET https://www.geeknow.top/v1/images/generations/async/task_img_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
task_id = "task_img_abc123"
resp = requests.get(
f"https://www.geeknow.top/v1/images/generations/async/{task_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(resp.json())
const taskId = "task_img_abc123";
const response = await fetch(
`https://www.geeknow.top/v1/images/generations/async/${taskId}`,
{
method: "GET",
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
}
);
console.log(await response.json());
响应示例
{
"id": "task_img_abc123",
"task_id": "task_img_abc123",
"object": "image.generation.task",
"model": "gpt-image-2-vip",
"status": "in_progress",
"progress": "10%",
"created_at": 1735689600
}
{
"data": [
{
"url": "https://geekm.oss-cn-shanghai.aliyuncs.com/image-generation-1783176295522148587.png"
}
],
"size": "1024x1024",
"usage": {
"input_tokens": 15,
"total_tokens": 211,
"output_tokens": 196,
"input_tokens_details": {
"text_tokens": 15
},
"output_tokens_details": {
"image_tokens": 196
}
}
}
{
"id": "task_img_abc123",
"task_id": "task_img_abc123",
"object": "image.generation.task",
"model": "gpt-image-2-vip",
"status": "failed",
"progress": "10%",
"created_at": 1735689600,
"error": {
"message": "Image generation failed",
"code": "generation_failed"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "Task not found",
"type": "invalid_request_error",
"param": "taskId",
"code": "task_not_found"
}
}
认证
Authorization: Bearer YOUR_API_KEY
Path Parameters
string
required
异步生图任务 ID。使用
POST /v1/images/generations/async 返回的 id、task_id 或 taskId。Response
string
任务 ID。
string
任务 ID 的兼容字段。
string
对象类型,通常为
image.generation.task。string
任务使用的图像模型,例如
gpt-image-2、gpt-image-2-pro、gpt-image-2.5-flare、gpt-image-2.5-sunburst、gpt-image-2-vip、doubao-seedream-4-0-250828、gemini-3-pro-image-preview 或 gemini-3.1-flash-lite-image。string
任务状态。常见值包括
queued、processing、in_progress、completed、succeeded、failed、cancelled。string
任务进度百分比。当前通道实测常见格式为字符串百分比,例如
10%。integer
任务创建时间戳。
string
输出尺寸,例如
1024x1024、1536x1024、3840x2160、3808x1632。string
最终结果对象的质量等级,例如
low;gpt-image-2.5-flare 与 gpt-image-2.5-sunburst 也可能返回 xhigh 或 max。string
任务完成后返回的图片 URL。
string
任务完成后返回的图片 Base64 数据。
string
上游改写后的提示词。是否返回取决于实际模型和通道。
object
失败原因对象。任务失败时读取
error.message 与 error.code。状态处理
| 状态 | 含义 | 建议处理 |
|---|---|---|
queued | 已提交,等待调度 | 继续轮询 |
processing / in_progress | 正在生成 | 继续轮询并展示 progress |
completed / succeeded | 已完成 | 读取 data[] 中的图片结果 |
failed | 任务失败 | 读取 error 并停止轮询 |
cancelled | 任务已取消 | 停止轮询 |
轮询建议
- 创建任务后先等待
2到5秒再开始查询。 - 常规轮询间隔建议为
3到5秒;长任务可以逐步退避到10秒。 - 业务侧应设置最大等待时间,避免无限轮询。
- 同一个
taskId可以重复查询,查询本身不会重新消耗一次生图任务。