claude-code - 💡(How to fix) Fix [BUG] Opus 4.7 on Bedrock fails with 'invalid beta flag' — Claude Code sends deprecated thinking API format [4 comments, 4 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#49490Fetched 2026-04-17 08:39:41
View on GitHub
Comments
4
Participants
4
Timeline
12
Reactions
3
Timeline (top)
labeled ×5commented ×4closed ×1cross-referenced ×1

Error Message

ANTHROPIC_LOG=debug output:

headers: { "anthropic-beta": "claude-code-20250219,effort-2025-11-24", } body: { thinking: [Object ...], anthropic_beta: [ "interleaved-thinking-2025-05-14" ], }

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

Root Cause

Root cause: Opus 4.7 (released April 16, 2026) introduced a breaking change to the thinking API:

Fix Action

Fix / Workaround

Workarounds attempted (none worked):

  • CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 — does not strip interleaved-thinking-2025-05-14 from the body
  • Changing effortLevel — no effect on the beta flag in the body

Code Example

body.anthropic_beta: ["interleaved-thinking-2025-05-14"]   ← rejected by Opus 4.7
body.thinking: {type: "enabled", budget_tokens: ...}       ← not supported by Opus 4.7

---

ANTHROPIC_LOG=debug output:

headers: {
  "anthropic-beta": "claude-code-20250219,effort-2025-11-24",
}
body: {
  thinking: [Object ...],
  anthropic_beta: [ "interleaved-thinking-2025-05-14" ],
}

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

---

{
     "env": {
       "CLAUDE_CODE_USE_BEDROCK": "1",
       "AWS_REGION": "us-west-2",
       "ANTHROPIC_MODEL": "us.anthropic.claude-opus-4-7"
     }
   }
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?

Claude Code v2.1.111 fails with a 400 "invalid beta flag" error when using Opus 4.7 (us.anthropic.claude-opus-4-7) on AWS Bedrock.

Root cause: Opus 4.7 (released April 16, 2026) introduced a breaking change to the thinking API:

  • Old (no longer supported by Opus 4.7): thinking.type: "enabled" with budget_tokens + anthropic_beta: ["interleaved-thinking-2025-05-14"]
  • New (required by Opus 4.7): thinking.type: "adaptive" with output_config: {effort: "high"} — no beta flag needed

Claude Code v2.1.111 still sends the old format to Bedrock's InvokeModel API:

body.anthropic_beta: ["interleaved-thinking-2025-05-14"]   ← rejected by Opus 4.7
body.thinking: {type: "enabled", budget_tokens: ...}       ← not supported by Opus 4.7

Verified via direct AWS CLI calls:

  • Opus 4.7 works on Bedrock without beta flags (basic messages succeed)
  • Opus 4.7 works with thinking.type: "adaptive" + output_config.effort
  • Opus 4.7 rejects anthropic_beta: ["interleaved-thinking-2025-05-14"] with "invalid beta flag"
  • Opus 4.7 rejects thinking.type: "enabled" with: "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.

What Should Happen?

Claude Code should detect Opus 4.7 on Bedrock and use the new adaptive thinking API format instead of the deprecated enabled/budget_tokens format.

Error Messages/Logs

ANTHROPIC_LOG=debug output:

headers: {
  "anthropic-beta": "claude-code-20250219,effort-2025-11-24",
}
body: {
  thinking: [Object ...],
  anthropic_beta: [ "interleaved-thinking-2025-05-14" ],
}

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

Steps to Reproduce

  1. Configure Claude Code for Bedrock with Opus 4.7:
    {
      "env": {
        "CLAUDE_CODE_USE_BEDROCK": "1",
        "AWS_REGION": "us-west-2",
        "ANTHROPIC_MODEL": "us.anthropic.claude-opus-4-7"
      }
    }
  2. Start Claude Code: claude
  3. Send any message — immediately fails with "invalid beta flag"

Workarounds attempted (none worked):

  • CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 — does not strip interleaved-thinking-2025-05-14 from the body
  • Changing effortLevel — no effect on the beta flag in the body

Claude Model

Opus

Is this a regression?

No — Opus 4.7 is a new model released today (April 16, 2026) with breaking API changes

Claude Code Version

2.1.111 (Claude Code)

Platform

AWS Bedrock Commercial

Operating System

macOS

Terminal/Shell

zsh

Additional Information

  • Model anthropic.claude-opus-4-7 is available and listed via aws bedrock list-foundation-models
  • Direct API calls via AWS CLI to us.anthropic.claude-opus-4-7 work correctly without beta flags
  • Opus 4.6 (anthropic.claude-opus-4-6-v1) continues to work fine with Claude Code
  • The first-party Anthropic API likely handles this correctly since opus alias resolves to 4.7 there; the issue is specific to the Bedrock InvokeModel path

extent analysis

TL;DR

Update Claude Code to use the new adaptive thinking API format for Opus 4.7 on Bedrock, replacing the deprecated enabled/budget_tokens format.

Guidance

  • Verify that the issue is indeed caused by the breaking change in Opus 4.7 by checking the API request body and ensuring it matches the old format.
  • Update the Claude Code configuration to use thinking.type: "adaptive" with output_config: {effort: "high"} for Opus 4.7 on Bedrock.
  • Remove the anthropic_beta flag from the request body, as it is no longer supported by Opus 4.7.
  • Test the updated configuration to ensure it resolves the "invalid beta flag" error.

Example

{
  "thinking": {
    "type": "adaptive",
    "output_config": {
      "effort": "high"
    }
  }
}

Notes

This fix assumes that the issue is solely caused by the breaking change in Opus 4.7 and that the updated adaptive thinking API format is correctly implemented in Claude Code.

Recommendation

Apply the workaround by updating the Claude Code configuration to use the new adaptive thinking API format for Opus 4.7 on Bedrock, as this is a breaking change introduced by the new model and not a regression in Claude Code.

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

claude-code - 💡(How to fix) Fix [BUG] Opus 4.7 on Bedrock fails with 'invalid beta flag' — Claude Code sends deprecated thinking API format [4 comments, 4 participants]