Skip to content

Claude Code context window: 1M, 200K, and what changes behind a gateway

Per Claude Code's model configuration docs (checked 2026-11-30), Fable models, Sonnet 5+, Haiku 5.5, and Opus 4.7+ use a 1M-token context window by default, while Opus 4.6 and Sonnet 4.6 stay at 200K unless you append [1m]. Behind a custom ANTHROPIC_BASE_URL gateway, recognized models keep their Anthropic API window from v2.1.285 on; unrecognized IDs assume 1M from v2.1.323 (200K earlier) and print a warning.

Which models default to 1M, and which require [1m]

Claude Code divides 1M-capable models into two groups (checked 2026-11-30 on code.claude.com/docs/en/model-config). Native 1M models need no suffix, whether the session uses the Anthropic API, a cloud platform, Claude apps gateway or a custom ANTHROPIC_BASE_URL. Opus 4.6 and Sonnet 4.6 default to 200K and opt into 1M via [1m].

terminal
# Quote [1m] in zsh to prevent glob expansion
claude --model 'claude-opus-4-6[1m]'
export ANTHROPIC_MODEL='claude-sonnet-4-6[1m]'
# Inside a session:
/model claude-opus-4-6[1m]
Which models default to 1M, and which require [1m]
Model familyDefault windowHow to get 1M
Fable, Sonnet 5+, Haiku 5.5, Opus 4.7+1M tokensBuilt in — no [1m] suffix needed
Opus 4.6 (claude-opus-4-6)200K tokensAppend [1m] (claude-opus-4-6[1m]); on direct Anthropic API, included on Max/Ultra/Team/Enterprise, needs usage credits on Pro, full access on API billing
Sonnet 4.6 (claude-sonnet-4-6)200K tokensAppend [1m] (claude-sonnet-4-6[1m]); on direct Anthropic API, needs usage credits on all subscription plans, full access on API billing
Haiku 4.5 (claude-haiku-4-5)200K tokens200K maximum (no 1M variant)
  • Quote [1m] when you pass it as a command argument in zsh: an unquoted bracket is read as a filename pattern and fails with "no matches found" before launch.
  • Claude Code strips [1m] before sending HTTP requests, so the upstream API or gateway receives only the base model ID.
  • When ANTHROPIC_BASE_URL points at a gateway and your saved claude.ai login is still the active credential, Claude Code (v2.1.229+) does not check your plan's usage credits: the [1m] options stay in /model and the gateway decides whether the request succeeds.

Behind an ANTHROPIC_BASE_URL gateway — and the two unrecognized-model warnings

Since v2.1.285, behind ANTHROPIC_BASE_URL, Claude Code gives recognized model IDs their Anthropic API window (changelog and model-config docs, checked 2026-11-30). It cannot detect a lower cap enforced by a proxy: if your gateway caps prompts at 200K, set CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000 to compact early. For an unrecognized model ID, Claude Code assumes 1M from v2.1.323 (200K earlier) and prints one of these two warnings (quoted from the docs):

Claude Code warning
⚠ Model "my-gateway-opus" isn't recognized · context assumed to be 1m tokens · ...
Claude Code doesn't recognize the model "my-gateway-opus", so it assumes a context window of 1m tokens. Update Claude Code, or see https://code.claude.com/docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id to set the window.
  • Meaning: Claude Code compacts against the assumed window (1M on v2.1.323+). If the real model is smaller, requests can hit prompt-too-long before compaction runs.
  • Newer model than your CLI: run claude update so the build recognizes the ID.
  • Gateway alias for a known Claude model: map the Anthropic ID in settings.json with modelOverrides (e.g. "claude-opus-5-5": "anthropic/claude-opus-5.5") or modelPicker behavesAs to restore the real window and clear the warning.
  • Custom window size: append [1m] for a 1M model, or set CLAUDE_CODE_MAX_CONTEXT_TOKENS for an eligible ID class below.

Context controls, environment variables, and default auto-compact thresholds

Each context and compaction control has a distinct scope and precedence (checked 2026-11-30 against model-config and env-vars docs):

Context controls, environment variables, and default auto-compact thresholds
Setting or variableWhat it controlsPrecedence and caveats
modelOverrides / modelPicker behavesAsMaps a known Anthropic ID to a gateway ID in settings.json.Applies the real window and capabilities and clears unrecognized-model warnings.
[1m] suffixOpts Opus 4.6, Sonnet 4.6, or an unrecognized ID into 1M.Stripped before the API call; quote in zsh. Ignored when CLAUDE_CODE_DISABLE_1M_CONTEXT=1.
CLAUDE_CODE_MAX_CONTEXT_TOKENSDeclares the window for custom deployments.Standalone only on unrecognized IDs without [1m] (claude-* IDs need v2.1.324+). With [1m], values under 1M also require CLAUDE_CODE_DISABLE_1M_CONTEXT=1 (values >200K log an expected "200K limit isn't enforced" note). On recognized IDs, it applies only with DISABLE_COMPACT, which disables all compaction.
CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT=1Disables proactive compaction on unrecognized IDs (v2.1.223+).Compacts reactively only on a recognized prompt-is-too-long API error; fails if a gateway rewrites that error.
CLAUDE_CODE_DISABLE_1M_CONTEXT=1Holds models that run with 1M by default to a 200K window and removes [1m] variants from /model.Native-1M models compact at 200K (higher auto-compact settings cannot exceed it) or error at 200K when auto-compact is off.
CLAUDE_CODE_AUTO_COMPACT_WINDOWGlobal auto-compact threshold (100000 to 1M, capped at model window).Overrides --autocompact, /autocompact (current model only from v2.1.288), and autoCompactWindow. Bare digits are exact tokens (200 clamps to 100k with a warning); k/M suffixes need v2.1.304+. Status-line used_percentage still uses the full window.
/autocompact <size|auto> (current model, v2.1.288+) & --autocompactCurrent model only (/autocompact from v2.1.288) or per-launch (--autocompact) compaction limit.Accepts 200000, 500k, 1M, or bare 100–1000 as thousands. From v2.1.288, /autocompact writes per-model modelSettings (earlier: autoCompactWindow); --autocompact bypasses managed settings.
  • Default thresholds (checked 2026-11-30): native-1M models (Fable, Sonnet 5+, Haiku 5.5, Opus 4.7+) auto-compact around 967K tokens; Opus 4.6 and Sonnet 4.6 without [1m], or native-1M models with CLAUDE_CODE_DISABLE_1M_CONTEXT=1, compact at 200K.
  • Unrecognized IDs compact at the assumed window (1M from v2.1.323, 200K earlier). Cloud sessions compact near the cap, and idleCompaction can compact idle threads.

Haiku 5.5 and the 100,000-token prompt threshold

Per Anthropic's model configuration docs (checked 2026-11-30), on the Anthropic API Claude Haiku 5.5 (claude-haiku-5-5) runs with the 1M window on every plan, with no [1m] suffix, and auto-compacts around 967K tokens. Once a Haiku 5.5 prompt exceeds 100,000 tokens, however, it costs more per token. To compact at about that size on every model, set CLAUDE_CODE_AUTO_COMPACT_WINDOW=100000, the smallest value it accepts (or run /autocompact 100k, which from v2.1.288 saves for the current model only); one turn that adds a large file or tool result can still go over 100,000.

Using Claude Code through Router One

Configure ANTHROPIC_BASE_URL=https://api.router.one (no /v1), set ANTHROPIC_AUTH_TOKEN to your Router One key, and leave ANTHROPIC_API_KEY unset (it is not required). Prefer hyphenated Anthropic IDs (claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5, claude-fable-5-2, claude-opus-5, claude-sonnet-5, claude-haiku-4-5): a Claude Code version that knows the model recognizes them directly. If a shared config uses dotted catalog IDs, map them via modelOverrides. Router One catalog and plan rules on 2026-11-30 (cross-provider comparison at /llm-context-window):

claude-code-context.sh
export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_AUTH_TOKEN=sk-your-router-one-key
unset ANTHROPIC_API_KEY  # not required on Router One
export ANTHROPIC_MODEL=claude-opus-5
# Optional: compact before the 256K step at which Opus 5 draws 2 plan requests
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=240000
Using Claude Code through Router One
Claude Code ID (catalog ID)Catalog context window (2026-11-30)Long-prompt rate & plan quota rules (2026-11-30)
claude-opus-5-5, claude-sonnet-5-5, claude-fable-5-2 (anthropic/claude-...)1,048,576Single wallet rate across the window; not in 2026-11-30 Pro/Max/Ultra tiers (wallet billing)
claude-haiku-5-5 (anthropic/claude-haiku-5.5)1,048,576Higher catalog rate tier above 100,000 input tokens; not in 2026-11-30 plans (wallet billing)
claude-opus-5, claude-sonnet-5 (anthropic/claude-opus-5, anthropic/claude-sonnet-5)1,048,576Single wallet rate; in 2026-11-30 Premium / Mid tiers where >256,000 tokens draw 2 plan units and >512,000 draw 4 (same for Opus 4.6, Opus 4.8 and Sonnet 4.6)
claude-haiku-4-5 (anthropic/claude-haiku-4.5)200,000Single wallet rate; in the Standard tier of Pro, Max and Ultra plans

FAQ

Why does /context show 200K instead of 1M in Claude Code?

Usually one of four causes: you selected Opus 4.6 or Sonnet 4.6 without [1m] (or Haiku 4.5, capped at 200K); CLAUDE_CODE_DISABLE_1M_CONTEXT=1 is set; your CLI is older than v2.1.285 and runs behind ANTHROPIC_BASE_URL, where earlier builds did not use the 1M window of native-1M models; or it is older than v2.1.323 with an unrecognized gateway ID, which earlier builds assumed to be 200K.

Why does Claude Code say 1M context is unavailable or hide [1m]?

On the direct Anthropic API, Opus 4.6 [1m] requires usage credits on Pro, and Sonnet 4.6 [1m] requires usage credits on every subscription plan. Locally, CLAUDE_CODE_DISABLE_1M_CONTEXT=1 removes [1m]. Behind ANTHROPIC_BASE_URL with a claude.ai login still the active credential, v2.1.229 and later no longer reject [1m] over usage credits.

What does "Model ... isn't recognized · context assumed to be 1m tokens" mean?

Claude Code could not match the model ID to a built-in definition, so from v2.1.323 it assumes 1M and compacts against it. Run claude update, use a hyphenated Anthropic ID such as claude-opus-5-5, map it via modelOverrides, or set CLAUDE_CODE_MAX_CONTEXT_TOKENS for an unrecognized non-[1m] ID.

What should I do when Claude Code's context window is full?

Use /compact to summarize the active session, or /clear when switching tasks so old file reads stop re-sending. To stay ahead of the ceiling automatically across every model, set CLAUDE_CODE_AUTO_COMPACT_WINDOW=240000 (or run /autocompact 240k, saved for the current model only from v2.1.288).

How do I turn off 1M context in Claude Code?

Export CLAUDE_CODE_DISABLE_1M_CONTEXT=1 (or add it to env in ~/.claude/settings.json) and restart. It removes [1m] variants from /model and holds native-1M models to 200K.

Why did CLAUDE_CODE_AUTO_COMPACT_WINDOW=200 warn and compact at 100K?

In that environment variable, bare digits mean exact tokens, so 200 is clamped up to the 100,000-token minimum with a warning. Use 200000 — or 200k on v2.1.304+. Bare 100–1000 means thousands only in /autocompact (current model only from v2.1.288) and --autocompact.

Does [1m] need quotes in zsh, and does it reach the gateway?

In zsh, yes when it is a command argument: write claude --model 'claude-opus-4-6[1m]', otherwise the brackets are read as a filename pattern and the command fails with "no matches found". Claude Code strips [1m] before the HTTP request, so the gateway receives only the base model ID.