Use encrypted reasoning content
Use encrypted reasoning content
Pass include: ["reasoning.encrypted_content"] on the Responses API so the reply includes an encrypted thinking item. Send that prior response.output (reasoning item plus message) back as part of the next request input to continue with reasoning context.
You need this for multi-turn with store: false / ZDR, after the 30-day server retention window, and for prompt-cache hits on reasoning models. Omitting prior reasoning is a top cache-miss cause. Treat the encrypted blob as opaque. Use a reasoning model.
Request with include
curl https://api.x.ai/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-m 3600 \
-d '{
"model": "grok-4.6",
"input": [
{"role": "system", "content": "You are Grok, an AI agent built to answer helpful questions."},
{"role": "user", "content": "How big is the universe?"}
],
"include": ["reasoning.encrypted_content"]
}'
import os
import httpx
from openai import OpenAI
client = OpenAI(
base_url="https://api.x.ai/v1",
api_key=os.getenv("XAI_API_KEY"),
timeout=httpx.Timeout(3600.0),
)
response = client.responses.create(
model="grok-4.6",
input=[
{"role": "system", "content": "You are Grok, an AI agent built to answer helpful questions."},
{"role": "user", "content": "How big is the universe?"},
],
include=["reasoning.encrypted_content"],
)
print(response.id)
print(response.output)
xAI SDK
import os
from xai_sdk import Client
from xai_sdk.chat import system, user
client = Client(api_key=os.getenv("XAI_API_KEY"), timeout=3600)
chat = client.chat.create(
model="grok-4.6",
use_encrypted_content=True,
)
chat.append(system("You are Grok, an AI agent built to answer helpful questions."))
chat.append(user("How big is the universe?"))
response = chat.sample()
print(response.content)
Follow-up: spread prior output
second_response = client.responses.create(
model="grok-4.6",
input=[
*response.output, # includes reasoning item with encrypted_content
{"role": "user", "content": "How do stars form?"},
],
include=["reasoning.encrypted_content"],
)
print(second_response.output_text)
# After the first response, paste its output items (reasoning + message)
# before the new user turn, and keep include on each turn you want encrypted back.
curl https://api.x.ai/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-m 3600 \
-d '{
"model": "grok-4.6",
"input": [
{"id": "rs_...", "type": "reasoning", "status": "completed", "summary": [], "encrypted_content": "<opaque>"},
{"id": "msg_...", "type": "message", "role": "assistant", "status": "completed", "content": [{"type": "output_text", "text": "..."}]},
{"role": "user", "content": "How do stars form?"}
],
"include": ["reasoning.encrypted_content"]
}'
Vercel AI SDK includes encrypted reasoning automatically unless you set store: false.
Pitfalls
- Use a reasoning model. Non-reasoning models will not return useful encrypted thinking.
- Do not parse or edit
encrypted_content. Store it and send it back unchanged. - With
store: falseor after 30 days, you must keep local history plus encrypted content yourself. - Console API credits are separate from SuperGrok's weekly pool on grok.com.