Opus 4.7 on Bedrock fails with "invalid beta flag" - Claude Code sends unsupported beta headers
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using Claude Code v2.1.111 with Bedrock (CLAUDE_CODE_USE_BEDROCK=1) and setting the model to eu.anthropic.claude-opus-4-7, every API request fails with:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"invalid beta flag"}}
Root cause: Claude Code sends beta flags that Bedrock's Opus 4.7 endpoint does not accept. Specifically:
- Header betas (
anthropic-betaHTTP header):claude-code-20250219,effort-2025-11-24— these are set because Claude Code uses thebeta.messages.stream()SDK path, which always attaches them as headers. The Bedrock SDK then forwards them to the API alongside body betas.
- Body beta (
anthropic_betain request body):tool-search-tool-2025-10-19— injected when ToolSearch deferred tool is enabled (default).
Bedrock Opus 4.7 only accepts interleaved-thinking-2025-05-14. All other betas return 400 invalid beta flag.
Verified via:
- Proxy intercept showing exact headers/body sent
- Direct
aws bedrock-runtime invoke-modelcalls testing each beta individually: interleaved-thinking-2025-05-14— ACCEPTEDclaude-code-20250219— REJECTEDeffort-2025-11-24— REJECTEDtool-search-tool-2025-10-19— REJECTEDcontext-1m-2025-08-07— REJECTED
What Should Happen?
Claude Code should not send beta flags that are unsupported by the target model on Bedrock. Opus 4.7 should work out of the box when selected via /model or settings.json.
The mG6 bedrock-allowed beta set (interleaved-thinking-2025-05-14, context-1m-2025-08-07, tool-search-tool-2025-10-19) only filters body betas via HS6(). The header betas (claude-code-20250219, effort-2025-11-24) bypass this filter entirely because they're set by the SDK's beta.messages namespace and go through as HTTP headers.
Error Messages/Logs
API Error: 400 {"type":"error","request_id":"req_...","error":{"type":"invalid_request_error","message":"invalid beta flag"}}
Debug log (`--debug-file`) shows:
[API REQUEST] /model/eu.anthropic.claude-opus-4-7/invoke-with-response-stream source=sdk
[ERROR] API error (attempt 1/11): 400 400 {"type":"error","request_id":"...","error":{"type":"invalid_request_error","message":"invalid beta flag"}}
Proxy intercept of the actual request:
Header: anthropic-beta: claude-code-20250219,effort-2025-11-24
Body: anthropic_beta: ["interleaved-thinking-2025-05-14"]
Steps to Reproduce
- Configure Claude Code for Bedrock:
``json``
// ~/.claude/settings.json
{
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"AWS_PROFILE": "your-profile",
"AWS_REGION": "eu-west-1"
},
"model": "eu.anthropic.claude-opus-4-7"
}
- Ensure Opus 4.7 is available in your region:
aws bedrock list-foundation-models --by-provider anthropic --query "modelSummaries[?contains(modelId,'opus-4-7')]" - Run
claude -p "say hi" --model eu.anthropic.claude-opus-4-7 - Observe the "invalid beta flag" error
Workaround (confirmed working):
{
"env": {
"ENABLE_TOOL_SEARCH": "false",
"CLAUDE_CODE_SIMULATE_PROXY_USAGE": "1"
}
}
This disables tool-search-tool-2025-10-19 body beta and strips claude-code-20250219 + effort-2025-11-24 header betas. Trade-off: ToolSearch deferred tools stop working.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
N/A — Opus 4.7 has never worked with Claude Code on Bedrock.
Claude Code Version
2.1.111
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Analysis of the code path (from binary analysis of v2.1.111):
eV6()generates candidate betas for a model (always includesclaude-code-20250219for non-haiku)HS6()filters throughmG6(bedrock-allowed set:interleaved-thinking,context-1m,tool-search-tool) for body betas- Body betas go via
bt()→body.anthropic_beta - Header betas (
P_array) includeclaude-code-20250219andeffort-2025-11-24— these are NOT filtered for Bedrock - The Bedrock SDK's
buildRequest()only copies header→body ifbody.anthropic_betais not set, BUT Bedrock validates both header AND body betas independently
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗