# CLAUDE_CODE_MAX_OUTPUT_TOKENS

> It sets how many tokens Claude may write in one reply.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable

## Think of it like

It is like a page limit. One answer can only fill so much.

## Definition

CLAUDE_CODE_MAX_OUTPUT_TOKENS sets how many tokens Claude may write in one reply. The default and the top value depend on the model. A value over a model's top is cut down to it. For a model ID Claude Code does not know, the default is 32,000 and the top is 128,000. Raising it leaves less room in the chat before it is squeezed.

## Example

Jack's gateway model is not one Claude Code knows, so replies stop at 32,000 tokens. He raises this, and long files come out whole.

## Example code

```bash
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000
claude
```

Let replies run longer.

## Why it matters

Too low and long work stops halfway. Too high and the chat fills up sooner.

## Common mistake

Setting it as high as it goes. The space it takes comes out of the room for the chat itself.

## Three principles

- **Per reply.** Tokens Claude writes.
- **Cut to the model's top.** No error.
- **Costs chat room.** Compacts sooner.

## Related terms

- [Max Tokens](https://learn.benibix.com/term/ai/max-tokens)
- [Auto-Compact](https://learn.benibix.com/term/ai/auto-compact)
- [Context Window](https://learn.benibix.com/term/ai/context-window)
- [MAX_THINKING_TOKENS](https://learn.benibix.com/term/ai/max-thinking-tokens-variable)

![The auto-compact window and its percent set when a chat is squeezed. Output room comes off the top.](https://learn.benibix.com/diagrams/env-context-window.svg)

---

Source: https://learn.benibix.com/term/ai/claude-code-max-output-tokens-variable
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-16
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
