Claude Code output token maximum exceeded: the fix
"Claude's response exceeded the output token maximum" means one reply ran into the cap on how much Claude may write in a single response, often while writing one large file. Raise Claude Code's max output tokens environment variable up to your model's limit, or ask for the output in smaller pieces.
Contents
"Claude's response exceeded the output token maximum" means a single reply tried to write more than the request allowed, and Claude Code cut it off there. It often happens while Claude writes one large file in one go. Raise CLAUDE_CODE_MAX_OUTPUT_TOKENS up to your model's maximum, or ask for the file in parts.
The messages and settings below are from Anthropic's error reference and environment variables page, read on 24 October 2026.
The three messages, and what each one means#
Anthropic's reference lists two forms of the output error and one related 400:
| Message | What happened | Fix |
|---|---|---|
API Error: Claude's response exceeded the ... output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable. |
The reply reached the request's output cap | Raise the variable, or split the output |
API Error: Claude's response exceeded the 64000 output token maximum for a request sent without streaming. The CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable cannot raise this limit. |
A streaming request failed, Claude Code re-sent it without streaming, and that path stops at 64,000 tokens | Split the output; the variable won't help |
API Error: 400 ... max_tokens must be greater than thinking.budget_tokens |
The thinking budget left no room for the answer | Raise the output cap above the budget |
The number in the first message is whatever cap that request had. If yours said 32000, that was your request's cap. On 24 October 2026 the environment variables page gives 32,000 only as the default for a model ID Claude Code can't match to a model it knows, and says defaults and caps otherwise vary by model.
Before v2.1.299, a reply cut off on a re-sent, non-streaming request ended the turn with no message at all, as if it were complete. So on an older install a long file can stop halfway with no error, and updating Claude Code gets you the message instead.
How to raise CLAUDE_CODE_MAX_OUTPUT_TOKENS#
The variable sets "the maximum number of output tokens for most requests". Set it in one of two places.
To set it for one terminal, run the line before you start claude. On macOS, Linux or WSL:
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000
In PowerShell:
$env:CLAUDE_CODE_MAX_OUTPUT_TOKENS = "64000"
In the Windows Command Prompt:
set CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000
Claude Code reads shell variables only at startup, so quit and relaunch it after you set one. Put the export line in ~/.zshrc or ~/.bashrc to keep it.
For every session, add it to the env block of ~/.claude/settings.json (values are strings):
{
"env": {
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "64000"
}
}
A running session picks up a changed settings file when you save it, and when the shell and the file disagree, the file's value applies in most sessions. Our Claude Code environment variables list covers the other files (project, local, managed) and which one wins.
How high you can go#
The ceiling is the model's own output maximum, from Anthropic's models overview:
| Model | Max output (synchronous API) |
|---|---|
| Fable 5.1 | 128K tokens |
| Opus 5.5 | 128K tokens |
| Sonnet 5.5 | 128K tokens |
| Haiku 5.5 | 128K tokens |
Older models have their own figures on their model pages. A value above the model's cap does no harm, because Claude Code lowers it to the cap. The cap that applies is the one of the model the session runs on, and changing the model in Claude Code lists the four places that model is set and which one wins.
One side effect: a higher cap leaves less of the context window before auto-compaction starts, because Claude Code keeps that much room free for the reply. The variable is a ceiling on a single reply, so it doesn't change your plan's usage limits in either direction.
When the variable is not the fix#
If the message says "for a request sent without streaming", or the file is bigger than any cap, change the request instead:
- If Claude wrote part of the reply before it stopped, type
continuein the same interactive session. The partial text stays in the conversation. - Ask for the output in smaller pieces: one file per reply, or one section of a long file at a time.
- For a long file, ask Claude to create it with the first part and then add the rest in later edits.
This is the output side. "Prompt is too long" is the input side: the conversation itself no longer fits the context window, and the fixes there are different (Claude Code "Prompt is too long").
"max_tokens must be greater than thinking.budget_tokens"#
This 400 means the thinking budget is at least as large as the reply's whole allowance, so nothing is left for the answer. The error reference's fix is to raise CLAUDE_CODE_MAX_OUTPUT_TOKENS above the thinking budget; lowering MAX_THINKING_TOKENS does the same job from the other end.
It only concerns models that use a fixed thinking budget. Anthropic's models overview says the fixed budget_tokens mode is deprecated on Opus 4.6 and Sonnet 4.6 and not accepted on later models, which use adaptive thinking steered by effort. The env-vars page also says Claude Code caps MAX_THINKING_TOKENS at one token below the request's output cap, and never below 1,024.
Setting it in Shuriken#
Shuriken starts Claude Code for each chat itself, and on macOS and Linux it reads the variables your login shell exports. So an export line in ~/.zshrc or ~/.bashrc reaches the chats you start after you save the file; a line you type into one Terminal window doesn't. All your Claude accounts in Shuriken share one ~/.claude/settings.json, so its env block works there too, whichever account a chat runs on.
To give one project its own value, open the project's settings, then Agent setup › Environment, and add CLAUDE_CODE_MAX_OUTPUT_TOKENS. Every agent and script of that project gets it, on every device, and the values are kept encrypted in your account. A value in settings.json still wins over it, as it does over your shell. Claude Code reads its environment when it starts, so the next chat you open in that project uses the new value.
To set it once per project instead of once per terminal, download Shuriken.
Try the free tool: Claude limit reset tracker
Sources
- Error reference: request errors (Claude Code docs) (accessed 24 October 2026)
- Environment variables (Claude Code docs) (accessed 24 October 2026)
- Model configuration: extended thinking (Claude Code docs) (accessed 24 October 2026)
- Claude Code changelog (accessed 24 October 2026)
- Models overview: max output (Claude API docs) (accessed 24 October 2026)
Frequently asked questions
What is the highest value CLAUDE_CODE_MAX_OUTPUT_TOKENS accepts?
Your model's own output maximum. On 24 October 2026 Anthropic's models overview lists 128K output tokens for Fable 5.1, Opus 5.5, Sonnet 5.5 and Haiku 5.5. Claude Code lowers any higher value to the model's cap.
I raised the variable and still get the error. Why?
Check which message you get. The one that says "for a request sent without streaming" is a fixed 64,000-token limit the variable can't raise. Otherwise the variable may not have reached Claude Code: shell variables are read only when claude starts, and a value in a settings file's env block replaces the shell's.
Is the cut-off reply lost?
No. If Claude wrote some text before the cap, that text stays in the conversation, and Anthropic's error reference says to reply continue in an interactive session to get the rest.
What does "max_tokens must be greater than thinking.budget_tokens" mean?
The fixed thinking budget is at least as large as the whole reply allowance, so nothing is left for the answer. Raise CLAUDE_CODE_MAX_OUTPUT_TOKENS above the budget, or lower MAX_THINKING_TOKENS. It only applies to models that use a fixed budget.