Short answer
Prompt is too long means the request Claude Code sent didn't fit in the model's context window. The request is more than your conversation: it also carries the system prompt, tool definitions (including every MCP server's tools), memory files such as CLAUDE.md, and attached files.
To keep working:
- Run
/compactto summarize earlier turns, or/clearto start fresh. - Run
/contextto see what is using the window. - Disable MCP servers you aren't using with
/mcp disable <name>, and trim largeCLAUDE.mdfiles. - If auto-compact is off, turn it back on in
/config.
If the error shows up near 200K tokens on a model with a 1M window, and especially if you use a gateway or a custom model ID, Claude Code may not recognize the model ID. The last section explains the fix.
What the error looks like
The Claude Code error reference lists several forms. In an interactive session you usually see:
Context limit reached · /compact or /clear to continue
In -p output and in the transcript, the text is the bare form:
Prompt is too long
Longer variants tell you more about why:
| Message | What it means |
|---|---|
Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on |
Auto-compact is turned off in your user settings |
Prompt is too long · automatic compaction failed: <the underlying error> |
Claude Code tried to compact and hit another error, such as an unavailable model or an authentication failure |
Prompt is too long · this conversation is a single exchange and cannot be compacted — ... |
There are no earlier turns to summarize; one prompt plus what Claude Code sends with it fills the window |
Input is too long for requested model. |
The same condition as reported by Amazon Bedrock |
Underneath, the Claude API returns a 400 invalid_request_error ("prompt is too long") when the input alone exceeds the model's context window, according to Anthropic's context window docs.
How big is the window?
Per Anthropic's context window docs, current models such as Claude Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Sonnet 5, Opus 4.8 and Sonnet 4.6 have a 1M-token context window. Other models, including Claude Haiku 4.5 and Sonnet 4.5, have 200K.
Auto-compact is on by default and normally summarizes the conversation before the window fills, so you usually hit this error for one of these reasons:
- Auto-compact is turned off.
- A single prompt or attachment is too large, such as a big pasted log or a large file.
- The fixed overhead is large: many MCP servers, long
CLAUDE.mdfiles, many tools. - Automatic compaction itself failed on another error.
- Claude Code assumed a smaller window than the model really has.
How to fix it
Free space now.
/compactsummarizes earlier turns and keeps working. You can steer what it keeps:/compact focus on the auth bug fix./clearstarts a new conversation. Use it when/compactanswersNot enough messages to compact., which means the conversation is a single exchange with nothing earlier to summarize.
See what's filling the window. Run /context. It breaks usage down by system prompt, tools, memory files and messages.
Cut the fixed overhead.
/mcp disable <name>for MCP servers you don't need in this session. That removes their tool definitions from the context.- Trim large
CLAUDE.mdfiles, or move instructions into path-scoped rules that load only when relevant (memory docs). - For a single-exchange error, resend with less pasted text or smaller attachments.
Keep auto-compact on. If you turned it off in /config or with DISABLE_AUTO_COMPACT, turn it back on. If you keep it off, run /compact yourself before the window fills. You can also make it run earlier with /autocompact, for example /autocompact 500k.
Fix the underlying error first. If the message says automatic compaction failed:, /compact will fail on the same error until you fix it. For example, an authentication error needs a working key, not a shorter conversation.
"Prompt is too long" near 200K on a gateway or custom model ID
Claude Code needs to know the model's context window to decide when to compact. If it doesn't recognize the model ID, it assumes 200K and shows a startup warning like this (model configuration docs):
⚠ Model "my-gateway-opus" isn't recognized · context assumed to be 200k tokens · ...
If the model's real window is 200K, there's nothing to fix. Otherwise, pick whichever fits:
- The model is newer than your Claude Code. Run
claude update. - Your gateway uses its own name for a model Claude Code knows. Map it in settings with
modelOverrides, for example"claude-opus-4-8": "my-gateway-opus". - The model has a 1M window. Append
[1m]to the model ID, for exampleclaude --model 'my-gateway-opus[1m]'. - Any other window size. Set
CLAUDE_CODE_MAX_CONTEXT_TOKENS, for exampleCLAUDE_CODE_MAX_CONTEXT_TOKENS=400000, in the environment that starts Claude Code. Check the docs first for which IDs it applies to.
Running Claude Code through TeamoRouter
TeamoRouter is an API gateway with one key for Claude, GPT, Gemini and DeepSeek. Claude runs on the native Anthropic protocol (/v1/messages), so Claude Code only needs a base URL and a key. Billing is pay-per-use with no subscription, from a $5 top-up.
- Create an API key in the TeamoRouter console. It starts with
sk-teamo-. - Top up from $5. The top-up dialog takes cards. You can also click Pay with crypto and pay with USDT, USDC or ETH from Binance, OKX or any exchange app — the checkout shows which networks your amount supports (BEP20 works from $5). You don't need a wallet extension. Step by step: Pay for Claude with USDT.
- Set two variables (macOS and Linux):
export ANTHROPIC_BASE_URL=https://api.teamorouter.com
export ANTHROPIC_AUTH_TOKEN="your TeamoRouter API key"
claude
Leave /v1 off the base URL. GET /v1/models lists the model IDs you can use. If Claude Code shows the isn't recognized · context assumed to be 200k tokens warning at startup, run claude update first, then use the steps in the previous section. Windows commands and model settings are in Install and connect Claude Code.
FAQ
Will /compact lose my work?
It replaces earlier turns with a summary. Claude Code's docs say that the system prompt, CLAUDE.md, memory, skill descriptions and MCP tools reload afterwards, and recently modified files are re-read. Details from older turns can be lost, so use /compact <focus> to say what to keep.
Why does it happen on the first message of a new session? The single-exchange case: your one prompt plus the system prompt, tool definitions and attachments already fill the window. Remove attachments or MCP servers, then send again.
Does switching to another model help? Only if the other model has a bigger context window than the one you're on. Claude Code won't fall back to a model with a smaller window during compaction.
Is this the same as a usage limit?
No. A usage limit is about how much you've used in a period. Prompt is too long is about the size of one request.