OpenAI Responses
Compatible with OpenAI Responses API; supports text, multimodal input, and streaming events; successful responses follow the original Responses protocol without using choices.
- Route:
POST /v1/responses - Additional support:
POST /v1/responses/compact - Successful responses follow the original Responses protocol, without
code/data, and do not use Chat Completions'choices
Request Example
curl https://api.magickapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "这张图片里有什么?"
},
{
"type": "input_image",
"image_url": "https://openai-documentation.vercel.app/images/cat_and_otter.png"
}
]
}
]
}'Successful Response Example
{
"id": "resp_123",
"object": "response",
"created_at": 1712345678,
"status": "completed",
"model": "gpt-5",
"output": [
{
"id": "msg_123",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "图中有一只猫和一只水獭。",
"annotations": []
}
]
}
],
"parallel_tool_calls": true,
"tools": [],
"usage": {
"input_tokens": 156,
"output_tokens": 45,
"total_tokens": 201
}
}Streaming Instructions
When "stream": true is passed, the native Responses event stream is returned, for example:
data: {"type":"response.output_text.delta","delta":"图中"}
data: {"type":"response.output_text.delta","delta":"有一只猫"}
data: {"type":"response.completed","response":{"id":"resp_123","status":"completed"}}
data: [DONE]Error Response Example
{
"error": {
"message": "Invalid request",
"type": "invalid_request_error",
"param": null,
"code": "invalid_request"
}
}Common Parameters
model
- Type:
string - Required: Yes
input
-
Type:
array | string -
Required: Yes
Consistent with the OpenAI Responses protocol, content types such as
input_text,input_image,input_filecan be mixed.
instructions
- Type:
string
previous_response_id
- Type:
string
tools
-
Type:
arrayThe current project passes through the Responses tool fields.
functiontools can be used directly; whether built-in tools likeweb_search_preview,file_searchare available depends on the specific upstream model and channel capabilities.
tool_choice
- Type:
string | object
stream
- Type:
boolean
stream_options
- Type:
object
/v1/responses/compact
This route is suitable for clients that need to compress context or continue conversations. The current project only accepts these core fields:
modelinputinstructionsprevious_response_id
Last updated on
Gemini Native Format
Use Gemini native paths and native request bodies; supports generateContent and streamGenerateContent; successful responses are Gemini original JSON.
GPT Image 2
Describes the integration status of `gpt-image-2` in the current project, as well as the request fields and response structure of the unified image interface.