xAI has introduced the Responses API as the recommended method for interacting with its models, including Grok 4.5. This new API provides an alternative to the legacy Chat Completions API, with key differences in how responses are structured and how multi-turn conversations are managed.
The Responses API returns content within an output array containing typed items. In contrast, the Chat Completions API delivers content in choices[0].message.content.
Key Points
- The Responses API is the recommended method for interacting with xAI models.
- The Chat Completions API returns content in
choices[0].message.content. - The Responses API returns content in an
outputarray with typed items. - Multi-turn conversations with the Chat Completions API require resending the entire conversation history with each request.
- The Responses API allows continuing a conversation using
previous_response_idwithout resending full history. - Migration from the Chat Completions API to the Responses API involves updating code to use
client.responses.createand renamingmessagestoinput. - The Grok 4 model is used in examples for the Responses API.
Context
According to xAI, the Responses API simplifies interaction with their models. The legacy Chat Completions API requires developers to manage conversation history by resending it with each turn. The Responses API introduces a mechanism to reference previous interactions, potentially reducing overhead for multi-turn dialogues.
Why It Matters
Developers working with xAI models can adopt the Responses API to manage conversation state more efficiently and handle structured outputs. This change impacts how applications are built to maintain context across multiple user interactions, potentially simplifying code and reducing token usage for repeated context.
What To Do
- Review the xAI documentation for the Responses API to understand the new response format.
- Test the
previous_response_idfeature in the Responses API for multi-turn conversations. - Update existing code from
client.chat.completions.createtoclient.responses.createand renamemessagestoinputwhere applicable. - Note the use of Grok 4 in the provided code examples for the Responses API.
Keep Exploring
/atlas/grok-family