Encrypted Reasoning
On this page
Internal reasoning in Grok models
Recent reasoning models (like grok-4.20-0309-reasoning) perform internal reasoning before producing their response. This thought process, normally invisible, can be retrieved in encrypted form using the include parameter. You can then reinject it into subsequent requests to maintain reasoning continuity.
Why is reasoning encrypted?
Internal reasoning contains the model’s raw thought process—intermediate steps, tested hypotheses, abandoned paths. xAI encrypts this content for two reasons:
- Intellectual property: Reasoning reveals the model’s internal workings
- Continuity: Encrypted content can be reused by the model to resume its thought process
You can’t read the encrypted content, but the model can decrypt and use it.
Retrieving encrypted reasoning
Add include=["reasoning.encrypted_content"] to your request:
response = client.responses.create(
model="grok-4.20-0309-reasoning",
input="Solve this problem: if a train leaves Paris at 2 PM at 200 km/h "
"and another from Lyon at 3 PM at 300 km/h, when do they meet?",
include=["reasoning.encrypted_content"]
)
The response will contain an additional field with the encrypted reasoning:
{
"output": [
{
"type": "reasoning",
"encrypted_content": "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6..."
},
{
"type": "message",
"content": [{"type": "output_text", "text": "The two trains meet at..."}]
}
]
}
Reusing reasoning in a conversation
The main benefit of encrypted reasoning is reinjecting it into subsequent requests. This allows the model to resume exactly where it left off in its thought process:
# Request 1: initial problem
response1 = client.responses.create(
model="grok-4.20-0309-reasoning",
input="Prove that the square root of 2 is irrational.",
include=["reasoning.encrypted_content"]
)
# Extract encrypted reasoning
encrypted = None
for item in response1.output:
if item.type == "reasoning":
encrypted = item.encrypted_content
break
# Request 2: go deeper while maintaining reasoning
response2 = client.responses.create(
model="grok-4.20-0309-reasoning",
input="Can you generalize this proof to roots of prime numbers?",
previous_response_id=response1.id,
include=["reasoning.encrypted_content"]
)
Encrypted reasoning vs. classic chaining
| Approach | Textual context | Reasoning continuity |
|---|---|---|
previous_response_id alone | Yes | No — the model restarts its reasoning |
previous_response_id + encrypted reasoning | Yes | Yes — the model resumes its chain of thought |
The difference is subtle but important for complex reasoning tasks. With encrypted content, the model doesn’t just reread the context: it resumes its internal thought process.
When to use encrypted reasoning?
Recommended
The common thread across these use cases is always the same: a conversation where turn N+1 must build on the reasoning from turn N. A math problem solved in multiple steps loses all coherence if the model forgets its path between two messages; a logical analysis conducted through successive deep dives needs its intermediate hypotheses; iterative debugging—“what if we test with this value?”—only makes sense if the model remembers what it has already eliminated. More generally, as soon as you notice that reasoning quality degrades from one turn to the next in your conversations, that’s the signal that the reasoning context is lost: reinjecting encrypted reasoning is precisely the remedy.
Not necessary
- Simple conversations (factual Q&A)
- Creative content generation
- Tasks that don’t require structured reasoning
Billing impact
Encrypted reasoning tokens are counted in output_tokens_details.reasoning_tokens. They are billed at the same rate as standard output tokens. The reasoning volume can be significant—sometimes 2 to 5 times more than the visible response.
Key takeaways
- Encrypted reasoning is retrieved with
include=["reasoning.encrypted_content"] - Content is encrypted—you can’t read it, but the model can reuse it
- Combined with
previous_response_id, it maintains chain-of-thought continuity - Useful for complex multi-step reasoning tasks
- Reasoning tokens are billed even if they are invisible in the response