xAI has introduced the Responses API as the primary interface for its models, according to xAI Docs. This new API replaces the Chat Completions API, which is now considered a legacy endpoint. New capabilities and features will be delivered through the Responses API first.
Key Points
- The Responses API is the recommended method for interacting with xAI models.
- The Chat Completions API is a deprecated legacy endpoint.
- Response formats differ, with Responses API using an
outputarray with typed items, unlike thechoices[0].message.contentstructure of Chat Completions. - Responses API supports multi-turn conversations by allowing the use of
previous_response_id. - The Chat Completions API requires resending the entire conversation history for multi-turn interactions.
- Deferred chat completions, available via REST requests or the xAI SDK, allow retrieving a result once within 24 hours.
- Deferred completion results are discarded after 24 hours if not retrieved.
Context
According to xAI Docs, the Chat Completions API was a popular feature used for tasks such as summarizing articles, generating creative writing, answering questions, providing customer support, and assisting with coding. However, new features will now prioritize the Responses API. Developers are advised to migrate to the new API, with migration guides available.
Why It Matters
Developers building with xAI models must transition to the Responses API to access new features and ensure compatibility. The change impacts how conversation history is managed and how responses are structured, requiring adjustments in application code.
What To Do
- Review the xAI Docs for the Responses API to understand its structure and capabilities.
- Consult the migration guide for transitioning from the Chat Completions API to the Responses API.
- Note the new response format, which uses an
outputarray with typed items. - Implement
previous_response_idfor multi-turn conversations when using the Responses API. - For long-running inference requests, explore deferred chat completions via REST requests or the xAI SDK, noting the 24-hour retrieval window.
