curl --request POST \
--url https://api.aiid.edu.kg/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-2k",
"input": "生成一张 2K 横屏产品海报,白色运动鞋,干净棚拍光线,高级商业摄影风格。",
"stream": false,
"tools": [
{
"type": "image_generation"
}
],
"background": true
}
'{
"id": "resp_xxx",
"created_at": 1780649146,
"error": null,
"incomplete_details": null,
"instructions": null,
"metadata": {
"task_id": "010c31178d26436ca6194cde07931b33"
},
"model": "gpt-image-2-2k",
"object": "response",
"output": [],
"parallel_tool_calls": true,
"temperature": null,
"tool_choice": null,
"tools": null,
"top_p": null,
"max_output_tokens": null,
"previous_response_id": null,
"reasoning": null,
"status": "queued",
"text": null,
"truncation": null,
"usage": null,
"user": null,
"store": null
}OpenAI格式(Responses)
建立回應 (OpenAI Responses API)
OpenAI Responses API,用於建立模型回應。 支援多輪對話、工具呼叫、推理等功能。
補充 OpenAI Responses API 的圖片生成非同步用例。background=true 用於提交背景任務,建立介面會立即回傳 status=queued 和完整 id,隨後使用該 id 呼叫 GET /v1/responses/{response_id} 查詢結果。
非同步圖片生成流程
- 呼叫
POST /v1/responses,請求體中傳入tools=[{ "type": "image_generation" }]且background=true。 - 保存建立介面回傳的完整
id,例如resp_xxx。不要截斷、重寫或只保存metadata.task_id。 - 呼叫
GET /v1/responses/{response_id}查詢,直到status=completed或status=failed。 - 成功後讀取
output[].url取得圖片連結。
建立非同步圖片任務範例
POST /v1/responses
Content-Type: application/json
{
"model": "gpt-image-2-2k",
"input": "生成一张 2K 横屏产品海报,白色运动鞋,干净棚拍光线,高级商业摄影风格。",
"stream": false,
"tools": [
{
"type": "image_generation"
}
],
"background": true
}
使用參考圖編輯並指定畫幅比例
input 可傳入訊息陣列;在同一則使用者訊息的 content 中混排 input_text 和 input_image。tools[].ratio 指定生成畫幅比例。
{
"model": "gpt-image-2-2k",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "生成新图片 4K, 16:9"
},
{
"type": "input_image",
"image_url": "https://imageproxy.zhongzhuan.chat/api/proxy/image/70a98de9c9d48160812454b4ee21edbf.jpg",
"detail": "auto"
}
]
}
],
"stream": false,
"tools": [
{
"type": "image_generation",
"ratio": "16:9"
}
],
"background": true
}
此範例的 model 為 gpt-image-2-2k;若需要 4K 等級,請改用 gpt-image-2-4k,不要只在提示詞中寫「4K」。
建立介面回傳範例:
{
"id": "resp_xxx",
"created_at": 1780649146,
"error": null,
"incomplete_details": null,
"instructions": null,
"metadata": {
"task_id": "010c31178d26436ca6194cde07931b33"
},
"model": "gpt-image-2-2k",
"object": "response",
"output": [],
"parallel_tool_calls": true,
"temperature": null,
"tool_choice": null,
"tools": null,
"top_p": null,
"max_output_tokens": null,
"previous_response_id": null,
"reasoning": null,
"status": "queued",
"text": null,
"truncation": null,
"usage": null,
"user": null,
"store": null
}
支援模型:gpt-image-2-2k、gpt-image-2-4k、nano-banana-pro。
POST
/
v1
/
responses
curl --request POST \
--url https://api.aiid.edu.kg/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-2k",
"input": "生成一张 2K 横屏产品海报,白色运动鞋,干净棚拍光线,高级商业摄影风格。",
"stream": false,
"tools": [
{
"type": "image_generation"
}
],
"background": true
}
'{
"id": "resp_xxx",
"created_at": 1780649146,
"error": null,
"incomplete_details": null,
"instructions": null,
"metadata": {
"task_id": "010c31178d26436ca6194cde07931b33"
},
"model": "gpt-image-2-2k",
"object": "response",
"output": [],
"parallel_tool_calls": true,
"temperature": null,
"tool_choice": null,
"tools": null,
"top_p": null,
"max_output_tokens": null,
"previous_response_id": null,
"reasoning": null,
"status": "queued",
"text": null,
"truncation": null,
"usage": null,
"user": null,
"store": null
}授權
使用 Bearer Token 認證。
格式: Authorization: Bearer sk-xxxxxx
主體
application/json
The body is of type object.
回應
200 - application/json
成功建立回應
範例:
"response"
可用選項:
completed, failed, in_progress, incomplete Hide child attributes
Hide child attributes
提示詞 Token 數
補全 Token 數
總 Token 數
