Why the Responses API?
On this page
A New Endpoint for New Ambitions
The Responses API is the primary new endpoint from xAI for interacting with Grok models. If you are already familiar with the Chat Completions endpoint (OpenAI-compatible), you are probably wondering why xAI created a second endpoint. The answer comes down to one word: evolution.
Chat Completions remains available for backward compatibility with OpenAI SDKs, but xAI adds all new platform features to the Responses API first. This is the endpoint worth your learning investment.
Stateful vs. Stateless: The Fundamental Change
The most important difference between the two endpoints is how they handle conversation state.
Chat Completions (stateless)
With Chat Completions, every request is independent. You must send the entire conversation history with every call:
{
"model": "grok-4.20-0309-reasoning",
"messages": [
{"role": "system", "content": "You are an assistant."},
{"role": "user", "content": "Hello"},
{"role": "assistant", "content": "Hello! How can I help you?"},
{"role": "user", "content": "Tell me about AI."}
]
}
The longer the conversation, the larger the request. You manage the context yourself.
Responses API (stateful)
With the Responses API, the xAI server retains the history. You simply send your new message and a reference to the previous response:
{
"model": "grok-4.20-0309-reasoning",
"input": "Tell me about AI.",
"previous_response_id": "resp-abc123"
}
The server reconstructs the full context for you. Less data to transmit, less code to write, fewer possible errors.
Exclusive Features
Several features are available only through the Responses API:
- Native server tools:
web_search,x_search, andcode_interpreterrun directly on xAI servers, without any configuration on your end - Conversation chaining: via
previous_response_id, the model retains all context without you having to resend it - Persistent storage: with
store: true, your responses are retained for 30 days and retrievable via GET - Encrypted reasoning: retrieve the internal reasoning of recent Grok models in encrypted form to reuse in subsequent requests
- Granular cost tracking:
cost_in_nano_usdin every response for precise control over your spending
When to Use Which Endpoint?
Use Chat Completions only if you are migrating an existing project from the OpenAI API and cannot modify your code immediately.
For any new project, use the Responses API. It is simpler, more powerful, and will receive all future improvements to the xAI platform.
Key Takeaways
- The Responses API is xAI’s primary endpoint—Chat Completions is legacy
- It is stateful: the server manages conversation history
- It offers native server tools (web search, X, code interpreter)
- Persistent storage lets you resume conversations up to 30 days later
- Any new project should use the Responses API