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
Response
任务使用的图像模型,例如
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。状态处理
| 状态 | 含义 | 建议处理 |
|---|---|---|
queued | 已提交,等待调度 | 继续轮询 |
processing / in_progress | 正在生成 | 继续轮询并展示 progress |
completed / succeeded | 已完成 | 读取 data[] 中的图片结果 |
failed | 任务失败 | 读取 error 并停止轮询 |
cancelled | 任务已取消 | 停止轮询 |
轮询建议
- 创建任务后先等待
2到5秒再开始查询。 - 常规轮询间隔建议为
3到5秒;长任务可以逐步退避到10秒。 - 业务侧应设置最大等待时间,避免无限轮询。
- 同一个
taskId可以重复查询,查询本身不会重新消耗一次生图任务。