claude-code - 💡(How to fix) Fix Bedrock: Opus 4.7 rejects all beta flags with 'invalid beta flag' error [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#49648Fetched 2026-04-17 08:35:14
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Claude Code v2.1.112 sends beta flags (e.g. claude-code-20250219, interleaved-thinking-2025-05-14) to Amazon Bedrock when using global.anthropic.claude-opus-4-7, but Bedrock's Opus 4.7 rejects all beta flags with a 400 error.

Error Message

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

Root Cause

Three places in cli.js add beta flags that Opus 4.7 on Bedrock does not accept:

  1. KR function — already filters iv1 set for Bedrock, but iv1 does not include claude-code-20250219
  2. DV8 function — when isAgenticQuery=true, forcibly pushes claude-code-20250219 even if KR returned []
  3. WV1.buildRequest — converts anthropic-beta header to body.anthropic_beta without stripping unsupported flags

Fix Action

Workaround

In DV8, skip the isAgenticQuery push for Opus 4.7 on Bedrock.
In WV1.buildRequest, delete q.body.anthropic_beta when the model includes opus-4-7.

Code Example

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

---

curl -X POST https://bedrock-runtime.ap-northeast-1.amazonaws.com/model/global.anthropic.claude-opus-4-7/invoke \
  -H "Authorization: Bearer $AWS_BEARER_TOKEN_BEDROCK" \
  -d '{"anthropic_version":"bedrock-2023-05-31","max_tokens":32,"messages":[{"role":"user","content":"hi"}]}'
# → 200 OK
RAW_BUFFERClick to expand / collapse

Summary

Claude Code v2.1.112 sends beta flags (e.g. claude-code-20250219, interleaved-thinking-2025-05-14) to Amazon Bedrock when using global.anthropic.claude-opus-4-7, but Bedrock's Opus 4.7 rejects all beta flags with a 400 error.

Environment

  • Claude Code: v2.1.112
  • Provider: Amazon Bedrock (CLAUDE_CODE_USE_BEDROCK=1)
  • Auth: Bedrock API Key (AWS_BEARER_TOKEN_BEDROCK)
  • Region: ap-northeast-1
  • Model: global.anthropic.claude-opus-4-7 (inference profile, ACTIVE)

Error

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

Root Cause

Three places in cli.js add beta flags that Opus 4.7 on Bedrock does not accept:

  1. KR function — already filters iv1 set for Bedrock, but iv1 does not include claude-code-20250219
  2. DV8 function — when isAgenticQuery=true, forcibly pushes claude-code-20250219 even if KR returned []
  3. WV1.buildRequest — converts anthropic-beta header to body.anthropic_beta without stripping unsupported flags

Verification

Opus 4.6 (global.anthropic.claude-opus-4-6-v1) accepts claude-code-20250219 on Bedrock — this is an Opus 4.7-specific regression.

Direct API calls with no beta flags work fine:

curl -X POST https://bedrock-runtime.ap-northeast-1.amazonaws.com/model/global.anthropic.claude-opus-4-7/invoke \
  -H "Authorization: Bearer $AWS_BEARER_TOKEN_BEDROCK" \
  -d '{"anthropic_version":"bedrock-2023-05-31","max_tokens":32,"messages":[{"role":"user","content":"hi"}]}'
# → 200 OK

Workaround

In DV8, skip the isAgenticQuery push for Opus 4.7 on Bedrock.
In WV1.buildRequest, delete q.body.anthropic_beta when the model includes opus-4-7.

Related

  • v2.1.101 fixed CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS not suppressing beta headers for Bedrock/Vertex — similar class of issue.
  • global.anthropic.claude-opus-4-7 inference profile was added to Bedrock on 2026-04-15.

extent analysis

TL;DR

Remove or filter out unsupported beta flags for Opus 4.7 on Amazon Bedrock to resolve the 400 error.

Guidance

  • Identify and modify the KR function in cli.js to filter out claude-code-20250219 and other unsupported beta flags for Opus 4.7 on Bedrock.
  • Update the DV8 function to skip pushing claude-code-20250219 when isAgenticQuery=true for Opus 4.7 on Bedrock.
  • Modify WV1.buildRequest to delete q.body.anthropic_beta when the model includes opus-4-7 to prevent sending unsupported beta flags.
  • Verify the fix by testing API calls with the modified code and checking for a 200 OK response.

Example

No code snippet is provided as the issue does not contain sufficient code context, but the modifications should be made in the cli.js file, specifically in the KR, DV8, and WV1.buildRequest functions.

Notes

The issue is specific to Opus 4.7 on Amazon Bedrock and does not affect Opus 4.6. The modifications should only be applied when using Opus 4.7 on Bedrock to avoid introducing regressions in other environments.

Recommendation

Apply the workaround by modifying the DV8 function and WV1.buildRequest as described, as this is a targeted fix for the specific issue with Opus 4.7 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