API Error: 400 invalid beta flag (Claude Code on Bedrock, Vertex or a gateway)
Claude Code sent an anthropic-beta value the upstream rejects, often Bedrock behind a gateway. Update Claude Code, set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, or fix the gateway.
Summary
- Bedrock and Google Cloud accept only some anthropic-beta values; a gateway that forwards Anthropic-format requests to them passes the rest through.
- Since v2.1.314, Claude Code retries without a beta value the 400 names; a bare invalid beta flag makes it guess.
- CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 stops most pre-release values but not those for extended context, interleaved thinking, effort or ANTHROPIC_BETAS.
- Past regressions, such as 2.1.129 on Bedrock, were fixed in a later release, so update first.
On this page
A beta value the upstream does not know
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"invalid beta flag"}}
Claude Code asks for pre-release features through anthropic-beta values. Anthropic's API accepts them; Amazon Bedrock and Google Cloud's Agent Platform accept only a subset.
Anthropic's gateway compatibility guide explains when the subset is respected. With CLAUDE_CODE_USE_BEDROCK or CLAUDE_CODE_USE_VERTEX, Claude Code sends only the values those platforms accept. Behind an ANTHROPIC_BASE_URL gateway that speaks the Anthropic format, it sends the full set, and a gateway that forwards them to Bedrock or Google Cloud gets this 400 back.
Update Claude Code first
Several versions have shipped with a value Bedrock rejects:
- Issue #56595: 2.1.129 put
interleaved-thinking-2025-05-14,tool-search-tool-2025-10-19andextended-cache-ttl-2025-04-11into the request body on Bedrock. A maintainer said 2.1.132 fixed it; one user later reported it back after updating. Users tied it toENABLE_PROMPT_CACHING_1H, and the workaround at the time was the stable channel ornpm install -g @anthropic-ai/claude-code@2.1.128. - Issue #49648: on 2.1.112, Opus 4.7 on Bedrock rejected
claude-code-20250219andinterleaved-thinking-2025-05-14, which Opus 4.6 accepted. A direct request with no beta values returned 200.
Run claude update, then retry. Claude Code v2.1.314 and later also retry on their own: when a 400 names the rejected value, Claude Code resends without it. A bare invalid beta flag names nothing, so Claude Code guesses which value it was; if the guess misses, the 400 still reaches you.
Turn off pre-release values
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
With this set, Claude Code stops sending context management, beta tool fields such as strict and defer_loading, structured-output format, task budgets and MCP tool search, along with their anthropic-beta values. It leaves some in place: the values for extended context, interleaved thinking and effort (cloud providers accept those), the OAuth value subscriptions need, and anything you add yourself through ANTHROPIC_BETAS or CLAUDE_CODE_EXTRA_BODY. If ANTHROPIC_BETAS is set in your environment, check it; a value you added stays on every request.
The variable does not cover everything users have hit. In issue #82549, Claude Desktop through claude gateway to Bedrock still failed intermittently with invalid beta flag and tools.11.custom.defer_loading: Extra inputs are not permitted with 20 or more MCP tools, even with the variable and ENABLE_TOOL_SEARCH=false set. That issue was closed for inactivity without a fix.
If you run the gateway
The guide's fix is to keep header and body together and to forward errors as they are. Strip a beta value only together with the body field it enables, and return the upstream's 400 unmodified so Claude Code's retry can read it. If the upstream does not name the value, a message carrying capability_rejected: beta_header: followed by the value lets Claude Code retry without it.
Bedrock rejects other things Claude Code sends to newer models as well; see context_management: Extra inputs are not permitted and data retention mode 'default' is not available. The rest of Claude Code's 400s are on our Claude Code API Error 400 page.
Sources and checks
- Claude Code gateway compatibility guide
- anthropics/claude-code #56595: 2.1.129 sends unsupported anthropic_beta flags in request body that Bedrock rejects with 400
- anthropics/claude-code #49648: Bedrock: Opus 4.7 rejects all beta flags with 'invalid beta flag' error
- anthropics/claude-code #82549: Bedrock gateway mode: invalid beta flag / tools.N.custom.defer_loading 400s