Opus 4.7 on Bedrock fails with "invalid beta flag" - Claude Code sends unsupported beta headers

Resolved 💬 3 comments Opened Apr 16, 2026 by Blaise-g Closed Apr 20, 2026

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:

  1. Header betas (anthropic-beta HTTP header): claude-code-20250219,effort-2025-11-24 — these are set because Claude Code uses the beta.messages.stream() SDK path, which always attaches them as headers. The Bedrock SDK then forwards them to the API alongside body betas.
  1. Body beta (anthropic_beta in 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-model calls testing each beta individually:
  • interleaved-thinking-2025-05-14 — ACCEPTED
  • claude-code-20250219 — REJECTED
  • effort-2025-11-24 — REJECTED
  • tool-search-tool-2025-10-19 — REJECTED
  • context-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

  1. 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"
}
``

  1. Ensure Opus 4.7 is available in your region: aws bedrock list-foundation-models --by-provider anthropic --query "modelSummaries[?contains(modelId,'opus-4-7')]"
  2. Run claude -p "say hi" --model eu.anthropic.claude-opus-4-7
  3. 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):

  1. eV6() generates candidate betas for a model (always includes claude-code-20250219 for non-haiku)
  2. HS6() filters through mG6 (bedrock-allowed set: interleaved-thinking, context-1m, tool-search-tool) for body betas
  3. Body betas go via bt()body.anthropic_beta
  4. Header betas (P_ array) include claude-code-20250219 and effort-2025-11-24 — these are NOT filtered for Bedrock
  5. The Bedrock SDK's buildRequest() only copies header→body if body.anthropic_beta is not set, BUT Bedrock validates both header AND body betas independently

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗