Skip to main content
Mavera has migrated from the OpenAI Chat Completions format to the OpenAI Responses API format. This guide walks you through every change — endpoints, SDK methods, request/response shapes, streaming, tool calling, and structured outputs.
The Responses API is not a breaking version bump — it’s a new endpoint format. Your existing Chat Completions code will continue to work during the transition period, but all new features and documentation target the Responses API.

What Changed


Step-by-Step Migration

1. Update the SDK Method

The SDK method changes from chat.completions.create() to responses.create(). The input format also changes from messages to input. No SDK version change is required — the OpenAI SDK already supports both.

2. Move System Messages to instructions

System messages are no longer part of the messages array. Use the top-level instructions parameter instead. Instructions are appended to the persona’s built-in system prompt.

3. Update Streaming

The streaming interface changes from a flag-based approach to a dedicated stream method with named events.

4. Update Structured Outputs

The response_format parameter is replaced by text format configuration passed via extra_body. The parsed result moves from response.choices[0].message.parsed to response.parsed.

5. Update Tool Calling

Tool definitions change from a nested format to a flat format. Tool call results change from {role: "tool"} messages to {type: "function_call_output"} items.

Tool Definitions

Reading Tool Calls

Sending Tool Results


6. Update Response Parsing

The response shape changes significantly. Update all code that reads from the response object.

7. Update Error Handling

Error responses use the same format, but the retry logic should reference the new SDK method.

Migration Checklist

Use this checklist to verify your migration is complete:
  • Replace client.chat.completions.create() with client.responses.create()
  • Replace messages parameter with input parameter
  • Move system messages from messages array to instructions parameter
  • Update streaming to use client.responses.stream() and named events
  • Update response_format to text: {format: {...}} in extra_body
  • Flatten tool definitions (remove function wrapper)
  • Update tool result messages to {type: "function_call_output", call_id, output}
  • Update response parsing: .choices[0].message.content to .output[0].content[0].text
  • Update parsed access: .choices[0].message.parsed to .parsed
  • Update token field references: prompt_tokens to input_tokens, completion_tokens to output_tokens
  • Update finish detection: finish_reason == "stop" to status == "completed"
  • Update cURL endpoints from /chat/completions to /responses
  • Update error handling and retry logic to use new SDK method
  • Test all code paths (basic, streaming, tools, structured outputs, analysis mode)

Common Gotchas

The Responses API does not support {role: "system"} in the input array. Use the instructions parameter instead. If you include a system message in input, it will be ignored or cause an error.
The old {type: "function", function: {name, ...}} nested format will not work. Use the flat format: {type: "function", name: "...", description: "...", parameters: {...}}.
The field name changed from tool_call_id to call_id, and the message type changed from {role: "tool"} to {type: "function_call_output"}.
You can no longer use stream=True as a parameter. Instead, use client.responses.stream() which returns a context manager. Iterate over events and check event.type == 'response.output_text.delta'.
response_format is replaced by text in extra_body. The schema structure inside is the same, but the wrapping key is different: text: {format: {type: "json_schema", json_schema: {...}}}.
There are no more choices — the output is in response.output[]. Each output item has a type field ("message" for text, "function_call" for tool calls). Text content is at response.output[0].content[0].text.
In Python, persona_id is still passed via extra_body. In JavaScript, it’s still a top-level field with // @ts-ignore. This did not change.

See Also

Responses API

Full Responses API reference and usage guide

Migrate OpenAI to Mavera

Migrate from OpenAI to Mavera (base URL + persona)

Streaming Guide

Deep dive into streaming patterns

Function Calling Guide

Tool calling patterns and best practices