Create response (OpenAI Responses API)
OpenAI Format (Responses)
Create response (OpenAI Responses API)
OpenAI Responses API, used to create model responses. Supports multi-turn conversations, tool calling, reasoning, and other features.
Add asynchronous image generation examples for OpenAI Responses API. background=true is used to submit background tasks; the create API returns status=queued and the full id immediately, then use that id to call GET /v1/responses/{response_id} to query the result.
Asynchronous image generation flow
- Call
POST /v1/responses, and passtools=[{ "type": "image_generation" }]andbackground=truein the request body. - Save the full
idreturned by the create API, for exampleresp_xxx. Do not truncate, rewrite, or save onlymetadata.task_id. - Call
GET /v1/responses/{response_id}to query untilstatus=completedorstatus=failed. - After success, read
output[].urlto get the image URL.
Example of creating an asynchronous image task
POST /v1/responses
Content-Type: application/json
{
"model": "gpt-image-2-2k",
"input": "生成一张 2K 横屏产品海报,白色运动鞋,干净棚拍光线,高级商业摄影风格。",
"stream": false,
"tools": [
{
"type": "image_generation"
}
],
"background": true
}
Create API response example:
{
"id": "resp_xxx",
"created_at": 1780649146,
"error": null,
"incomplete_details": null,
"instructions": null,
"metadata": {
"task_id": "010c31178d26436ca6194cde07931b33",
"credits": "23"
},
"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
}
Supported models: gpt-image-2-2k, gpt-image-2-4k, and nano-banana-pro.
POST
Create response (OpenAI Responses API)
Authorizations
Use Bearer Token authentication.
Format: Authorization: Bearer sk-xxxxxx
Body
application/json
The body is of type object.
