Skip to content
BENIBIX Learn

CLAUDE_CODE_MAX_CONTEXT_TOKENS

AI⌨️ Claude CodeConfiguration

Also known as CLAUDE_CODE_MAX_CONTEXT_TOKENS environment variable

It tells Claude Code the model's real context size.

Think of it like

It is like you tell a friend the real size of a box. The label on it was wrong.

Example

Emma's gateway serves a model with a 128,000 token window under a Claude name. Chats crashed when full. She sets the real size, and they squeeze in time.

Why it matters

If Claude Code thinks the window is too big, a chat can spill over before it is squeezed.

Definition

CLAUDE_CODE_MAX_CONTEXT_TOKENS tells Claude Code the real size of the model's context window. Claude Code guesses the size from the model's name. But through a gateway, a name can hide a model of a different size. Set this so the squeeze point and the meter fit the real model.

Example code

bash
export ANTHROPIC_BASE_URL=https://llm.example.com
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=128000
claude
Match a gateway model's real window.

Common mistake

Setting it on a direct link to fit more in. It only describes the model. It cannot make the window bigger.

Key takeaways

  1. 1
    Says the real size. Not a bigger one.
  2. 2
    For gateways. Odd model names.
  3. 3
    Fixes the squeeze point. And the meter.