{
"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
}Tạo phản hồi (OpenAI Phản hồi API)
OpenAI Responses API, dùng để tạo phản hồi của mô hình. Hỗ trợ các tính năng như hội thoại đa vòng, gọi công cụ, suy luận.
Bổ sung các trường hợp sử dụng tạo ảnh bất đồng bộ cho OpenAI Responses API. background=true dùng để gửi tác vụ nền, API tạo sẽ trả về ngay status=queued và id đầy đủ, sau đó dùng id này để gọi GET /v1/responses/{response_id} truy vấn kết quả.
Quy trình tạo ảnh bất đồng bộ
- Gọi
POST /v1/responses, trong body của request truyềntools=[{ "type": "image_generation" }]vàbackground=true. - Lưu lại toàn bộ
iddo API tạo trả về, ví dụresp_xxx. Không cắt ngắn, viết lại hoặc chỉ lưumetadata.task_id. - Gọi
GET /v1/responses/{response_id}để truy vấn cho đến khistatus=completedhoặcstatus=failed. - Sau khi thành công, đọc
output[].urlđể lấy liên kết ảnh.
Ví dụ tạo tác vụ ảnh bất đồng bộ
POST /v1/responses
Content-Type: application/json
{
"model": "gpt-image-2-2k",
"input": "生成一张 2K 横屏产品海报,白色运动鞋,干净棚拍光线,高级商业摄影风格。",
"stream": false,
"tools": [
{
"type": "image_generation"
}
],
"background": true
}
Chỉnh sửa bằng hình ảnh tham chiếu và chỉ định tỷ lệ khung hình
input có thể truyền mảng tin nhắn; trong content của cùng một tin nhắn người dùng, có thể trộn input_text và input_image. tools[].ratio chỉ định tỷ lệ khung hình được tạo.
{
"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
}
Trong ví dụ này, model là gpt-image-2-2k; nếu cần mức 4K, hãy chuyển sang dùng gpt-image-2-4k, đừng chỉ viết “4K” trong prompt.
Ví dụ phản hồi của API tạo:
{
"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
}
Các model được hỗ trợ: gpt-image-2-2k, gpt-image-2-4k, nano-banana-pro.
{
"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
}Ủy quyền
Sử dụng xác thực Bearer Token.
Định dạng: Authorization: Bearer sk-xxxxxx
Nội dung
The body is of type object.
Phản hồi
Phản hồi tạo thành công
"response"
completed, failed, in_progress, incomplete Hide child attributes
Hide child attributes
Số lượng Token của lời nhắc
Số Token hoàn thiện
Tổng số Token
