Skip to content

Request Errors

400 returned, unrelated to content

Symptom: an AWS group returns 400 with invalid beta flag in the log, and it reproduces even in a new conversation.

Cause: Claude Code auto-attaches an experimental Beta header (anthropic-beta) that some AWS upstreams don't support.

Fix: confirm with an env var first:

bash
# Mac / Linux
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
claude

# Windows PowerShell
$env:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = "1"
claude

Once confirmed, write it to the global config ~/.claude/settings.json:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://your-request-address",
    "ANTHROPIC_API_KEY": "sk-***",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}

Fully close and reopen the terminal afterward.

Cause: a Claude Code bug produced a malformed request body.

Fix: resend the request, or run /compact — usually recovers.

413 request body too large

Symptom: API Error: 413 Request Entity Too Large.

Cause: too many tokens in the current context; the request body exceeds the server's size limit.

Fix: run /clear (clear conversation) or /compact (compress context into a summary), or quit and start a new session.

Prevention: run /compact periodically during long tasks.

400 Invalid model name

Symptom: API Error: 400 Invalid model name, seen with the Opus model.

Cause: insufficient Opus concurrency quota; the server downgrades and rejects.

Fix: no config change needed — wait a moment and retry. Don't waste time repeatedly editing config.

429 Rate Limit / quota exhausted

429 has two subtypes, handled completely differently:

  • rate_limit_error: too many requests in a short time; recovers automatically after waiting
  • insufficient_quota: this month's quota is used up; you must recharge or wait for next month's reset

How to tell: go to https://your-request-address to check your balance:

  • Usage not exhausted → rate limiting; wait or lower concurrency
  • Usage at zero → quota exhausted; go recharge

Overloaded / 500 error

Cause: the official service is overloaded or down.

Fix: check status.anthropic.com for service status and wait for recovery.

API Error: response exceeded the 32000

Cause: a single reply exceeds the default output token limit.

Fix: set in the env of ~/.claude/settings.json:

json
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000"

503 model_not_found

Cause: the selected model is offline or unavailable on the current channel.

Fix: use /model to switch to another available model, or contact your provider to confirm availability.

context window exceeded, conversation truncated

Cause: too many tokens accumulated in one session without timely /compact or a new session.

Fix: run /compact to compress context, or /clear to start fresh.

Command timed out after 2m 0.0s

Cause: Claude Code timed out waiting for a shell command to return — unrelated to the API request.

Fix: run the command manually in the terminal to see where it's stuck.