Responses API
OpenAI's next-generation stateful endpoint, with built-in support for tools, web search, file search, and multi-step tasks — gradually replacing Chat Completions.
Create a Response
POST /v1/responseshttps://test.kailin.com.cn/v1/responsesRequest
curl https://test.kailin.com.cn/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "gpt-4o-mini",
"input": "Describe the Responses API in one sentence"
}'
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name |
input | string / array | Yes | Input text, or an array of messages/content parts |
stream | boolean | No | Stream output (richer event types) |
instructions | string | No | System-level instructions |
previous_response_id | string | No | Pass the previous Response ID for multi-turn continuity without resending history |
tools | array | No | Tools: function, web_search_preview, etc. |
temperature / top_p | number | No | Sampling parameters |
max_output_tokens | number | No | Max output tokens |
metadata | object | No | Custom key-value pairs (up to 16) |
store | boolean | No | Whether to store the result for previous_response_id reference |
Example with an array input (including an image):
{
"model": "gpt-4o-mini",
"input": [
{
"role": "user",
"content": [
{ "type": "input_text", "text": "Describe this image" },
{ "type": "input_image", "image_url": "https://example.com/cat.jpg" }
]
}
]
}
Response
{
"id": "resp_abc123",
"object": "response",
"created_at": 1730000000,
"status": "completed",
"model": "gpt-4o-mini",
"output": [
{
"type": "message",
"id": "msg_abc123",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "The Responses API is OpenAI's next-generation stateful endpoint…",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 30,
"total_tokens": 42
}
}
To extract text, iterate output items with type: "message" and read content[].text; the SDK also offers the resp.output_text shortcut.
Retrieve a Response
GET /v1/responses/{response_id}curl https://test.kailin.com.cn/v1/responses/resp_abc123 \
-H "Authorization: Bearer sk-your-token"
Returns the full Response object. Responses created with store: false cannot be retrieved.
Compact Context
POST /v1/responses/compactCompacts a long conversation into a summary — useful for long-running agents to reduce token usage on subsequent requests:
curl https://test.kailin.com.cn/v1/responses/compact \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "gpt-4o-mini",
"input": [ ...long message array... ]
}'
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model used for compaction |
input | array | Yes | Message array to compact |
instructions | string | No | Custom instructions for the summary |
Returns the compacted summary object, which can be placed in the input of the next request.
WebSocket access (wss://.../v1/responses with response.create events) depends on gateway WS passthrough support — REST + SSE remains the primary client integration path and is not covered here.