claude-code - 💡(How to fix) Fix Opus 4.7 on Bedrock fails with "invalid beta flag" - Claude Code sends unsupported beta headers [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49370Fetched 2026-04-17 08:43:03
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
6
Author
Timeline (top)
labeled ×4cross-referenced ×2subscribed ×2commented ×1

Error Message

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"invalid beta flag"}}

Root Cause

Root cause: Claude Code sends beta flags that Bedrock's Opus 4.7 endpoint does not accept. Specifically:

Fix Action

Fix / Workaround

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.

Code Example

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"invalid beta flag"}}

---

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"]

---

// ~/.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"
   }

---

{
  "env": {
    "ENABLE_TOOL_SEARCH": "false",
    "CLAUDE_CODE_SIMULATE_PROXY_USAGE": "1"
  }
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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.

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

extent analysis

TL;DR

Disable unsupported beta flags by modifying the settings.json to exclude claude-code-20250219 and effort-2025-11-24 header betas and tool-search-tool-2025-10-19 body beta.

Guidance

  • Identify and filter out unsupported beta flags in the request headers and body to prevent 400 invalid beta flag errors.
  • Use the provided workaround by setting ENABLE_TOOL_SEARCH to false and CLAUDE_CODE_SIMULATE_PROXY_USAGE to 1 in settings.json to disable tool-search-tool-2025-10-19 body beta and strip unsupported header betas.
  • Verify the fix by checking the request headers and body for the presence of only supported beta flags, such as interleaved-thinking-2025-05-14.
  • Test the API request with the modified settings to ensure it no longer returns a 400 invalid beta flag error.

Example

{
  "env": {
    "ENABLE_TOOL_SEARCH": "false",
    "CLAUDE_CODE_SIMULATE_PROXY_USAGE": "1"
  }
}

This example demonstrates the workaround settings to disable unsupported beta flags.

Notes

The provided workaround has a trade-off, as it disables ToolSearch deferred tools. A more permanent solution would require modifying the Claude Code to dynamically filter out unsupported beta flags based on the target model.

Recommendation

Apply the workaround by setting ENABLE_TOOL_SEARCH to false and CLAUDE_CODE_SIMULATE_PROXY_USAGE to 1 in settings.json, as it has been confirmed to work and allows for temporary use of Opus 4.7 with Claude Code on Bedrock.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING