Response Storage and Persistence
On this page
Control the lifespan of your data
The Responses API includes built-in storage: with store: true, xAI servers keep your responses for 30 days. You can retrieve, view, and delete them at any time using dedicated endpoints.
store: true vs store: false
Stored mode (store: true)
{
"model": "grok-4.20-0309-reasoning",
"input": "Write a summary of this project.",
"store": true
}
The response persists for 30 days. You can:
- Reference it with
previous_response_idto continue the conversation - Retrieve it later with
GET /v1/responses/{id} - Delete it with
DELETE /v1/responses/{id}
Private mode (store: false)
{
"model": "grok-4.20-0309-reasoning",
"input": "Analyze this confidential data.",
"store": false
}
The response isn’t kept after the request. You still receive the result in the HTTP response, but it becomes inaccessible afterward. Chaining via previous_response_id isn’t possible.
Use store: false for sensitive data or when you don’t need to continue the conversation.
Retrieve a stored response
curl https://api.x.ai/v1/responses/resp-abc123 \
-H "Authorization: Bearer $XAI_API_KEY"
The API returns the complete response object, identical to the one received during creation. This is useful for:
- Auditing past interactions
- Reconstructing a conversation history
- Verifying costs after the fact
In Python
# Retrieve a stored response
stored = client.responses.retrieve("resp-abc123")
print(stored.output[0].content[0].text)
print(f"Cost: {stored.usage.cost_in_nano_usd / 1e9:.6f} USD")
Delete a response
curl -X DELETE https://api.x.ai/v1/responses/resp-abc123 \
-H "Authorization: Bearer $XAI_API_KEY"
Deletion is permanent. If other chained responses reference this response via previous_response_id, the corresponding context will no longer be available.
In Python
client.responses.delete("resp-abc123")
Storage use cases
Chatbot with history
Enable store: true for all requests. The user can resume their conversation even after closing the browser, as long as you keep the last response_id.
Sensitive data analysis
Use store: false for requests containing personal or confidential data. The response is processed in memory and not persisted.
Audit and compliance
Retrieve stored responses to build audit logs. Delete them when they’re no longer needed to comply with retention policies.
Retention period
Stored responses are automatically deleted after 30 days. You can’t extend this period via the API. If you need a longer history, save the responses in your own database.
Key takeaways
store: truepersists the response for 30 days —store: falsekeeps nothingGET /v1/responses/{id}retrieves a stored responseDELETE /v1/responses/{id}permanently deletes a response- Chaining via
previous_response_idrequires the response to be stored - Responses are automatically purged after 30 days
- Use
store: falsefor sensitive data