Claude Code on Amazon Bedrock: “Invalid Beta Flag” and Other Setup Errors

Claude Code on Amazon Bedrock: “Invalid Beta Flag” and Other Setup Errors

The Claude Code Bedrock invalid beta flag error means your request carried a feature label that Bedrock, or a gateway in front of it, won’t accept. Your AWS account and your project are fine. The fix is to stop sending that one label.

Run claude update first, because newer versions retry without the rejected label. Next, remove any custom value you added through ANTHROPIC_BETAS. If you reach Bedrock through a gateway, set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 before you start Claude Code.

If the error is still there, switch the gateway to the Bedrock route with CLAUDE_CODE_USE_BEDROCK=1, or ask its team which label was refused. Each step is below, along with the other Bedrock errors people hit: credentials, 403, region, model ID and streaming.

Browse all our Claude Code tutorials for more fixes and how-tos.

Tested with Claude Code v2.1.330 on macOS on November 22, 2026. We ran Claude Code against a small stand-in server on the same computer, set to answer with the exact error text, so no request went to AWS. Steps inside AWS follow Anthropic’s official docs.

Quick Summary

What you seeLikely causeFix
400 invalid beta flagA beta value was refusedUpdate, then turn experimental betas off
Extra inputs are not permittedA beta field arrived without its headerForward both, or turn betas off
Could not load AWS credentialsNo usable credentials on your computerSign in to AWS again
AWS authentication failedExpired token or missing permissionRefresh, then check IAM and model access
on-demand throughput isn’t supportedPlain model IDUse an inference profile ID
Bedrock streaming response has content-typeA gateway rewrote the streamPass the stream through untouched

What “Invalid Beta Flag” Means on Bedrock

Claude Code uses features that are still in preview. Each one has a label with a date, such as context-management-2025-06-27, and Claude Code sends those labels with every request. The docs call them anthropic-beta values.

Bedrock accepts a smaller set of labels than Anthropic’s own API. When a label outside that set arrives, the whole request is refused with a 400. Your prompt never reaches the model.

Here is the error we reproduced, followed by the setting that cleared it:

Terminal showing Claude Code API Error: 400 invalid beta flag, then the same command working after setting CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS to 1
Our stand-in server refused one beta value. Turning experimental betas off fixed it.

Why it usually happens behind a gateway

Many companies put a gateway between Claude Code and Bedrock. If you point at it with ANTHROPIC_BASE_URL, the docs say Claude Code treats it as the Claude API and can’t tell which service it forwards to. So it sends the full list of labels.

With CLAUDE_CODE_USE_BEDROCK=1, the docs say Claude Code sends only the labels Bedrock accepts. We logged both routes to see the difference.

Log of eight anthropic-beta values Claude Code sent through ANTHROPIC_BASE_URL, including context-management and per-turn-control
Through ANTHROPIC_BASE_URL, our server received eight beta values.
Log of the beta values Claude Code sent with CLAUDE_CODE_USE_BEDROCK set, three in the header and three in the request body
On the Bedrock route, it received five, some in the header and some in the request body.

The betas command in these shots is our own small script that prints the server’s log. The exact list depends on your version and model, so treat ours as an example. When we pinned Sonnet 4.6, for instance, one value disappeared.

Diagram comparing beta values sent by Claude Code: eight through ANTHROPIC_BASE_URL, five with CLAUDE_CODE_USE_BEDROCK, three with experimental betas turned off
The route you choose decides how many beta values go out.

The error names no value, so your job is to shorten the list until the refused one is gone.

How to Fix the Claude Code Bedrock Invalid Beta Flag Error

Work through these in order. Restart Claude Code after each change, because it reads these variables when it starts.

Decision diagram for the Claude Code Bedrock invalid beta flag error: update, remove ANTHROPIC_BETAS, turn experimental betas off or use the Bedrock route, then find the refused value
Start at the top. If a step doesn’t clear the error, take the next one.

Fix 1: Update Claude Code

claude update
claude --version

Recent versions can drop a refused label and try again on their own. The docs say most of the values this covers need v2.1.314 or later.

For a bare “invalid beta flag” with no name, Claude Code has to guess which label was refused. In our test on v2.1.330, it guessed right for the thinking token count label and for tool search. It didn’t recover when we refused the context management, per-turn control or interleaved thinking label.

Claude Code gateway docs explaining that for a bare invalid beta flag, Claude Code guesses which value the upstream rejected
The docs confirm it: with no name in the error, Claude Code guesses.

Fix 2: Remove values you added with ANTHROPIC_BETAS

ANTHROPIC_BETAS adds your own labels to requests. The docs warn that a value Claude Code doesn’t recognize stays on every request, so you keep getting the 400. The off switch in Fix 3 doesn’t remove it either.

Terminal showing invalid beta flag still failing with experimental betas disabled while ANTHROPIC_BETAS is set, then working after unset ANTHROPIC_BETAS
The off switch alone didn’t help here. Removing the custom value did.

Check your shell first, then look in the env block of your settings files. Not sure where those are? See settings.json locations.

echo $ANTHROPIC_BETAS
unset ANTHROPIC_BETAS

We saw one difference on the Bedrock route. Our made-up value wasn’t sent at all there, so this fix matters most with ANTHROPIC_BASE_URL.

Fix 3: Turn experimental betas off

export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
claude

To make it stick, put it in a settings file instead:

{
  "env": {
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}

In our logs this cut the list to three labels on both routes: claude-code, interleaved-thinking and effort. It also removed the context_management and defer_loading fields, which cause similar 400 errors.

Claude Code docs for CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, listing the pre-release capabilities it stops sending
The official list of what this setting turns off.

There is a cost. You lose context management and MCP tool search, so every MCP tool loads upfront. In our test, the number of tools sent with each request went from 12 to 22 on the Anthropic route and to 20 on the Bedrock route.

Fix 4: Use the Bedrock route on your gateway

Ask your gateway team if they offer a Bedrock address. If they do, use this block from the docs instead of ANTHROPIC_BASE_URL:

unset ANTHROPIC_BASE_URL
export ANTHROPIC_BEDROCK_BASE_URL=https://llm-gateway.example.com/bedrock
export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
export CLAUDE_CODE_USE_BEDROCK=1

The skip setting is for gateways that hold the AWS credentials for you. If the gateway needs its own token, add ANTHROPIC_AUTH_TOKEN and keep the skip setting on.

Claude Code docs showing the Amazon Bedrock gateway variables and the warning about AWS_BEARER_TOKEN_BEDROCK
Leave AWS_BEARER_TOKEN_BEDROCK unset when the gateway issues its own credential.

Fix 5: Find the label that is being refused

Fix 3 leaves the interleaved thinking label on. When our server refused that one, CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 still failed, and this setting cleared it:

export DISABLE_INTERLEAVED_THINKING=1

The better long-term fix belongs to whoever runs the gateway. If the error names the label, Claude Code can remove just that one. We changed our server to answer with the Unexpected value(s) sentence, and the second request went through.

Log showing Claude Code's first request refused with context-management named, and a second request without that value accepted
Same refused value as before, but this time the error named it.

Send your gateway team the gateway compatibility guide. It asks them to forward anthropic-beta unchanged and pass error messages through without rewording them.

Other Claude Code Bedrock Setup Errors

Extra inputs are not permitted

This is a close cousin. The label and its matching field should travel together, and this 400 appears when only the field arrives or the upstream doesn’t know it. Update to v2.1.305 or later, then use Fix 3 if you need to.

Our error 400 guide covers other causes.

Could not load AWS credentials

Claude Code found nothing to sign in with, so no request left your computer. We got it by turning Bedrock on with no AWS profile or keys set:

Claude Code API Error: Could not load AWS credentials, Could not load credentials from any providers
Bedrock is on, but there are no AWS credentials to use.

Sign in again and confirm it worked outside Claude Code:

aws sso login --profile your-profile-name
export AWS_PROFILE=your-profile-name
aws sts get-caller-identity

If the message ends with “default-chain credential resolve timed out,” your sign-in step stalled for 60 seconds. Finish any browser sign-in before you start Claude Code. For slow sign-ins, raise CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS.

AWS authentication failed (403)

Bedrock uses a 403 for both an expired token and a missing permission, so Claude Code can’t tell which one you have. Our test server’s 403 produced this message:

AWS authentication failed · refresh your AWS credentials (SSO sign-in, access keys, API key or proxy token) and retry · if credentials are current, check AWS permissions and model access · API Error: 403 ...

Refresh your credentials first. If that doesn’t help, check three things from the docs:

  • Your IAM policy allows bedrock:InvokeModel, bedrock:InvokeModelWithResponseStream, bedrock:ListInferenceProfiles and bedrock:GetInferenceProfile.
  • Someone submitted the use case form for Anthropic models in your AWS account. It’s needed once per account.
  • The model is enabled for your account and region.

Wrong region

Run /status to see which region and model Claude Code settled on. It checks AWS_REGION, then AWS_DEFAULT_REGION, then your AWS profile, and falls back to us-east-1.

Claude Code /status screen showing API provider Amazon Bedrock, the Bedrock base URL, AWS region eu-west-1 and the model eu.anthropic.claude-opus-5-5
With eu-west-1 set, Claude Code picked a model ID that starts with eu.

The region also decides the model prefix, such as us. or eu. in front of the model name.

If your account only has global. profiles, set ANTHROPIC_BEDROCK_REGION_PREFIX=global.

Amazon Bedrock page in the Claude Code docs, with region troubleshooting steps and the on-demand throughput fix
The docs’ steps for region trouble and the on-demand throughput error.

On-demand throughput isn’t supported

The docs’ fix is to specify the model as an inference profile ID. Those have a region prefix:

export ANTHROPIC_MODEL='us.anthropic.claude-sonnet-4-6'

Run aws bedrock list-inference-profiles --region your-region to see the IDs your account has. If Claude Code says the model itself is the problem, see our selected model error guide.

Bedrock streaming response has content-type “text/event-stream”

Bedrock streams its answers in a binary format. This error means a gateway turned that into something else:

Claude Code API Error: Bedrock streaming response has content-type text/event-stream, expected application/vnd.amazon.eventstream
We made the stand-in server send the wrong stream type to trigger this one.

The gateway should pass the response body and its Content-Type through unchanged. The setting named in the message only hides the check, and the docs say those requests then take a slower path.

Try It Yourself

Before you change anything, print the variables that choose your route. This shows names only, so no keys appear on screen:

env | grep -E '^(ANTHROPIC|CLAUDE_CODE|AWS|DISABLE)_' | cut -d= -f1 | sort

If you see both ANTHROPIC_BASE_URL and CLAUDE_CODE_USE_BEDROCK, decide which route you want and unset the other. Then test with one short prompt:

CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 claude -p "Reply with the word ready."

A reply here but not without the prefix means a preview label or its matching field was the problem.

Common Mistakes

  • Copying a list of beta labels from a forum into ANTHROPIC_BETAS. Claude Code already sends the ones it needs.
  • Letting a gateway strip anthropic-beta but keep the request body. That trades this error for “Extra inputs are not permitted.”
  • Setting AWS_BEARER_TOKEN_BEDROCK alongside a gateway token. The docs say the Bedrock key is sent instead.
  • Changing a variable in one terminal while Claude Code runs in another.
  • Using a Bedrock model ID such as us.anthropic.claude-sonnet-4-6 on the Mantle endpoint, which has its own IDs.

Pro Tips

  • Pin model versions for a team. The docs warn that aliases such as opus can point to a model your account doesn’t have yet.
  • Run /setup-bedrock to change your credentials, region or model pins in a wizard.
  • Remove the off switch from time to time and retest. Gateways get updated, and you’ll want tool search back.
  • Keep route settings in one place. Our list of environment variables shows what each one does.

For the full setup from scratch, follow our Bedrock setup guide. If a company proxy is also in the way, see corporate proxy setup.

Cheat Sheet

Cheat sheet for Claude Code on Amazon Bedrock errors: invalid beta flag steps, off switches, gateway variables, and region, model and credential checks
Save this card for the next Bedrock setup error.

Frequently Asked Questions

Is the invalid beta flag error a problem with my AWS account?

Usually not. It’s about what the request contains, so your credentials and permissions aren’t the cause. Account trouble tends to show up as a credentials error or a 403.

Which beta flag is invalid?

A bare “invalid beta flag” doesn’t say. Ask your gateway team to check their logs, or shorten the list with the off switches until the error stops.

What do I lose with CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1?

You lose preview features such as context management and MCP tool search, plus some beta tool fields. The effort and interleaved thinking labels stay on.

Can I get this error without a gateway?

It’s less likely, because Claude Code limits what it sends on the Bedrock route. If it happens, update Claude Code, check ANTHROPIC_BETAS, then try the off switches. Our common errors guide helps with anything else.

Does WebSearch work in Claude Code on Bedrock?

No. The Amazon Bedrock docs say the WebSearch tool isn’t available there, so a missing search tool isn’t a setup mistake.

Conclusion

The Claude Code Bedrock invalid beta flag error comes down to one preview label that Bedrock or your gateway won’t take. Update Claude Code, clear ANTHROPIC_BETAS, and set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 if you go through ANTHROPIC_BASE_URL; moving to the Bedrock route is the cleaner fix when your gateway offers it. In our tests on v2.1.330, an error that named the label let Claude Code recover with no changes at all, so it’s worth asking for. To learn more about the models you’re connecting to, see our overview of Claude AI.

Newsletter

New AI tools in your inbox

The best new tools and the AI news that matters, in one short email. Unsubscribe any time.

Free · No spam · Unsubscribe any time

✓ Looks like you’re subscribed

Loading Google’s sign-up form…

Looks like you’re already subscribed

Thanks for reading! New AI tools and the AI news that matters will land in your inbox.

Not subscribed yet? Refresh the page to load the sign-up form.

The sign-up form couldn’t load. If you use an ad or content blocker, allow news.google.com and reload the page.

Free instant check before you pay. Takes a few seconds.

Scroll to Top