Skip to main content
Lesson 6 of 16 · Responses API: Primary Endpoint

Response Storage and Persistence

Lesson 6 of 16 Updated July 30, 2026 Developer
On this page
  1. Control the lifespan of your data
  2. store: true vs store: false
  3. Retrieve a stored response
  4. Delete a response
  5. Storage use cases
  6. Retention period
  7. Key takeaways

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_id to 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: true persists the response for 30 days — store: false keeps nothing
  • GET /v1/responses/{id} retrieves a stored response
  • DELETE /v1/responses/{id} permanently deletes a response
  • Chaining via previous_response_id requires the response to be stored
  • Responses are automatically purged after 30 days
  • Use store: false for sensitive data