Chat Completions → Responses
Migrate Messages, Choices, and Chat streaming increments to Responses Input, Output Items, and events.
Chat Completions organizes conversations with messages and choices. Responses uses input, Typed Items, and output for inputs, tool calls, and results. Migration requires changes to the endpoint, input structure, response parsing, tool loop, and streaming state machine.
First, confirm that the model supports Responses
Support for Responses fields, events, and tools varies by model. Before migrating, confirm the model in the Model Marketplace and start with a minimal text request.
Whether migration is needed
Situations suitable for migration to Responses:
- The new project aims to use unified Typed Input and Output Items;
- Requires multi-turn state capability such as
previous_response_id; - Requires built-in tools supported by Responses;
- Applications are willing to handle text, utility calls, and other outputs according to Item types.
Situations where you can continue using Chat Completions:
- Existing applications relied on
messages,choices, and Chat Delta; - The target model or required tool only supports Chat Completions;
- Currently, there is not enough regression testing coverage tools, multi-turn, and streaming;
- The migration benefits are insufficient to cover the retrofit costs of response resolution and state management.
Core changes
| Chat Completions | Responses | Migration action |
|---|---|---|
POST /v1/chat/completions | POST /v1/responses | Change the Client method or request path |
messages | input / Input Items | Retain the role and content semantics, and switch to the Responses input structure |
| System or developer messages | instructions or Typed Input | Decide the boundaries of instructions and dialogue history |
max_completion_tokens | max_output_tokens | Change the field name |
response_format | text.format | Migrate the structured output configuration |
choices[].message | output[] Items | Traverse by Item and Content types |
tool_calls | function_call Item | Retain the function name, parameters, and call ID |
| Tool message | function_call_output item | Return the result with the matching call_id |
| Chat Delta | response.* Event | Rewrite streaming event dispatch |
prompt_tokens/ completion_tokens | input_tokens/ output_tokens | Update the usage read logic |
Minimum Request Before / After
{
"model": "MODEL_ID",
"messages": [
{
"role": "system",
"content": "Answers should be concise and accurate."
},
{
"role": "user",
"content": "Please introduce AGTCloud in one sentence."
}
]
}When using the OpenAI SDK, keep the client Base URL as https://api.agtcloud.cn/v1 and change the method from client.chat.completions.create(...) to client.responses.create(...). For complete Python and TypeScript initialization instructions, see OpenAI SDK.
Migration response read
Chat Completions usually reads the assistant message from the first Choice:
choices[0].message.contentResponses returns an ordered output[] array that can contain messages, function calls, search calls, and other items. The SDK's output_text helper reads aggregated text; when processing tools or other output types, traverse the complete output array.
response.output_text
response.output[]Do not assume output[0] must be text
Tool calls or other Items may appear before text messages. Dispatch each item by type, and retain logging or compatibility handling for item types the application does not yet recognize.
Migrate to multi-turn states
| Method | How to use | Notes |
|---|---|---|
| Client playback | Continue the historical Input and Output Items into the next input | Apps control their own saving, cropping, and privacy policies |
| Response association | Next request is previous_response_id | First, confirm that the target model and interface support this capability |
When using previous_response_id, the previous request's instructions are not inherited automatically. Set instructions for each turn according to the application's needs.
After migration, do not simultaneously replay the entire history and re-reference it via previous_response_id, as this may lead to repeated context.
Migrate Function Calling
Tool definition
Chat Completions puts function definitions in tools[].function:
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Check the city weather",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
}Responses places the function information directly in the Function Tool object:
{
"type": "function",
"name": "get_weather",
"description": "Check the city weather",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}Results are sent back
- Chat: Read calls from
assistant.tool_calls[], then add a tool message with the matchingtool_call_id. - Responses: Read
function_callitems fromoutput[], then sendfunction_call_outputwith the matchingcall_id.
No matter which protocol you use, the function is executed by your application. Do not directly execute unverified parameters, and do not disguise tool exceptions as normal results.
Migrate Streaming
Chat Completions returns incremental content in choices[].delta and commonly uses [DONE] to terminate the stream.
Responses use named events, such as:
response.created;response.output_item.added;response.content_part.added;response.output_text.delta;response.output_text.done;response.completed.
During migration, the original "text concatenation only" logic should be changed to an event dispatcher: first handle by event type, then update the corresponding status based on identifiers such as output_index, content_index, item_id.
Interruption does not mean completion
Only after receiving a completion event and confirming the response status should the round be marked as successful. Connection interruptions, failure events, and incomplete states must be handled independently.
Migrate Structured Outputs
Chat Completions uses response_format for output formatting, while Responses uses text.format. Update this configuration during migration:
- Request field location;
- JSON Schema wrapper structure;
- SDK parsing assistance methods;
- Handling of rejections, incomplete responses, and schema validation failures.
For detailed fields, please refer to Chat Completions and OpenAI Responses.
Migrating Web Search
The search entry points for the two protocols are different:
- Chat Completions uses
web_search_optionsand requires a model that supports web search; - Responses enables supported web search tools in
toolsand may return search-call items and citations.
Settings such as domain filtering, source listings, user location, and real-time internet access depend on the chosen protocol and model. For a full example, please refer to OpenAI Web Search.
Usage, errors, and interrupts
When migrating monitoring and billing read logic, at least adjust the following:
| Chat Completions | Responses |
|---|---|
usage.prompt_tokens | usage.input_tokens |
usage.completion_tokens | usage.output_tokens |
usage.total_tokens | usage.total_tokens |
finish_reason | Response, Item, and content status or error messages |
Record the HTTP status code, error object, and Request ID together. Do not capture only the SDK exception text. Application logs should distinguish authentication failures, unavailable models, rate limits, service errors, and connection interruptions.
Phased migration
Migrate the minimum text link
First, complete request creation and text parsing. Do not enable streaming, tools, or multi-turn state yet.
Modify Output Item assignment
Supports message and function calls, and remains compatible with unknown items, not discarding them directly.
Migration state and flow events
Verify client historical playback, previous_response_id, text increments, tool parameter increments, and termination events respectively.
Restore advanced abilities
Enable each item in the order of structured output, Web Search, and multimodal input, each retaining an independent regression use case.
Regression and Rollback Checklist
- Plain text, empty output, rejection, incomplete, and failed states;
- Single tool, multi-tool, tool failure, and parameter validation failure;
- Stateless history playback and
previous_response_id; - Streaming: Normal completion, disconnection, and repeated events;
- Structured Outputs validation failed;
- Usage, error messages, Request ID, timeout, and rate limiting;
- If the target model does not support a certain Responses capability, it can switch back to Chat Completions.
Before production switchover, keep separate configurations and controllable switches for Chat and Responses. After confirming that business metrics, logs, and error handling are stable, clean up old resolution paths.
Next
- Use OpenAI SDK to configure Python or TypeScript clients;
- View Text and Conversations to understand the daily invocation flow of Responses;
- Check the full fields and responses in OpenAI Responses;
- When encountering invocation errors, check Errors and Troubleshooting.