Fix Claude Code response exceeded 32000 output token maximum
Claude Code "exceeded the 32000 output token maximum" means a reply hit its output cap and was cut off. Reply continue, split the work, or raise the variable.
API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.One of Claude's replies reached the largest number of output tokens the request allowed and was cut off there. If part of it was already written, reply continue to get the rest; if it keeps happening, ask for less per reply or raise CLAUDE_CODE_MAX_OUTPUT_TOKENS within the model's cap. The number varies by situation; the official docs show the general form as exceeded the ... output token maximum.
[1] Check the end of the message. If it reads like this, raising the variable won't help.
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 and Claude Code re-sent it without streaming, which caps the reply at 64,000 tokens. Why the streaming failed matters more than the output cap here. If the same session showed Streaming response ended before any complete data was received. Retrying without streaming., the official docs name a proxy or gateway between Claude Code and the model provider that consumes or transforms the streaming body as the usual cause, and say to configure it to pass streaming bodies and headers through unmodified.
[2] If text written before the cut-off is on screen, reply continue in the interactive session. That text stays in the conversation, so Claude picks up from there. Asking for the whole thing again just gets cut at the same length.
[3] Ask for less per reply. The official docs suggest asking for one file or one section per reply.
- Writing a large new file: "outline and function list first → only function A → only function B"
- Editing many files: one file per turn
- Summarizing long documents or logs: one chunk at a time
[4] If you really need long replies, raise the variable. In a shell, export it before launching claude; to keep it, put it in the env block of a settings file.
$ export CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000$ claude{ "env": { "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "64000" }}Each model has a fixed cap, and Claude Code lowers any value above it to the cap. The per-model defaults and caps are in the comparison table of the Claude models overview. The docs also note that a higher value shrinks the context available before auto-compaction, so raise it only for the work that needs it and remove it afterwards.
[5] A different message involves the thinking budget.
API Error: 400 ... max_tokens must be greater than thinking.budget_tokensThe extended thinking budget is larger than the output limit, leaving no room for the answer. Raise CLAUDE_CODE_MAX_OUTPUT_TOKENS above the thinking budget.
Scripts run with claude -p cannot just send continue the way an interactive session can. An issue (#69434, closed) reported losing the whole session when the final turn exceeded the limit, so split non-interactive jobs small from the start, as in [3]. For replies cut off in code that calls the API directly, see Check stop_reason to Tell If a Claude Response Was Cut Off.