[BUG] Bedrock, 3.7

Status Fixed / completed
Maintainer reply None cached
Activity 10 comments · opened Mar 18, 2025 · closed May 27, 2025

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [X] AWS Bedrock
  • [ ] Google Vertex AI
  • Claude CLI version:0.2.48 (Claude Code)
  • Operating System: macOS
  • Terminal: iTerm2

Bug Description

Claude Code doesn't seem to work with Sonnet 3.7.
It does work with Sonnet 3.5, while, I get a 403 error with 3.7.

Steps to Reproduce

  1. This works correctly with 3.5: ANTHROPIC_MODEL='us.anthropic.claude-3-5-sonnet-20241022-v2:0' CLAUDE_CODE_USE_BEDROCK=1 DISABLE_PROMPT_CACHING=1 claude
  2. This does not work: ANTHROPIC_MODEL='us.anthropic.claude-3-7-sonnet-20250219-v1:0' CLAUDE_CODE_USE_BEDROCK=1 DISABLE_PROMPT_CACHING=1 claude and I get: API Error: 403 You don't have access to the model with the specified model ID

However, claude 3.7 is indeed enabled and working in a python shell, as in the following example:

import boto3
bedrock = boto3.client(service_name='bedrock-runtime')
response = bedrock.invoke_model(
                modelId='us.anthropic.claude-3-7-sonnet-20250219-v1:0',
                body=json.dumps(
                    {
                        "anthropic_version": "bedrock-2023-05-31",
                        "max_tokens": 2000,
                        "messages": [
                            {
                                "role": "user",
                                "content": [{"type": "text", "text": "Hello"}],
                            }
                        ],
                    }
                ),
            )
print(json.loads(response.get("body").read())["content"][0]["text"])

That returns:

Hello! How can I assist you today?

View original on GitHub ↗

10 Comments

mark-os · 1 year ago

You are in the wrong AWS region, check your AWS_REGION_NAME and AWS_DEFAULT_REGION environment variables.

leotac · 1 year ago

Not sure I understand. Explicitly setting the region/default region doesn't help.

This works (with 3.5):
ANTHROPIC_MODEL='us.anthropic.claude-3-5-sonnet-20241022-v2:0' CLAUDE_CODE_USE_BEDROCK=1 DISABLE_PROMPT_CACHING=1 AWS_REGION_NAME='us-west-2' AWS_DEFAULT_REGION='us-west-2' claude

This works (with 3.7): a python script that calls claude 3.7 with boto3, called with AWS_REGION_NAME='us-west-2' AWS_DEFAULT_REGION='us-west-2', or explicitly specifiying region_name='us-west-2' when instantiating the client.

This doesn't (with 3.7):
ANTHROPIC_MODEL='us.anthropic.claude-3-7-sonnet-20250219-v1:0' CLAUDE_CODE_USE_BEDROCK=1 DISABLE_PROMPT_CACHING=1 AWS_REGION_NAME='us-west-2' AWS_DEFAULT_REGION='us-west-2' claude

claude 3.7 also works with other tools such as Aider.

ppearcy · 1 year ago

Hi @leotac , not sure if this is useful, but I was having some similar errors. I enabled all models in all regions I had access to. I am sure this was overkill, but it resolved my issue. I likely just needed specific models in US regions.

My default region was also us-west-2.

bfeeley35 · 1 year ago

I just got this command to work for a single instance deployed to us-east-2 and region=us-east-2 in my .aws/config file:
AWS_REGION='us-east-2' ANTHROPIC_MODEL='us.anthropic.claude-3-7-sonnet-20250219-v1:0' CLAUDE_CODE_USE_BEDROCK=1 CLAUDE_CODE_DEBUG=1 DISABLE_PROMPT_CACHING=1 claude

arpagon · 1 year ago
I just got this command to work for a single instance deployed to us-east-2 and region=us-east-2 in my .aws/config file: AWS_REGION='us-east-2' ANTHROPIC_MODEL='us.anthropic.claude-3-7-sonnet-20250219-v1:0' CLAUDE_CODE_USE_BEDROCK=1 CLAUDE_CODE_DEBUG=1 DISABLE_PROMPT_CACHING=1 claude

Works for me

guilleojeda · 1 year ago

It seems us.anthropic.claude-3-7-sonnet-20250219-v1:0 routes to us-east-2. I'm trying to figure out why and how to avoid it. But I also got this to work from us-east-2 and fail from us-east-1

hutchisr · 1 year ago
I just got this command to work for a single instance deployed to us-east-2 and region=us-east-2 in my .aws/config file: AWS_REGION='us-east-2' ANTHROPIC_MODEL='us.anthropic.claude-3-7-sonnet-20250219-v1:0' CLAUDE_CODE_USE_BEDROCK=1 CLAUDE_CODE_DEBUG=1 DISABLE_PROMPT_CACHING=1 claude

Unfortunately does not work for me

leotac · 1 year ago
You are in the wrong AWS region, check your AWS_REGION_NAME and AWS_DEFAULT_REGION environment variables.

FYI, this ended up being a very trivial env variable issue.
Blindly following this comment I initially set AWS_DEFAULT_REGION and AWS_REGION_NAME.
But the variable that should be set is AWS_REGION 😅
Doing that, everything works (assuming of course the model is enabled in that region).

mark-os · 1 year ago
> You are in the wrong AWS region, check your AWS_REGION_NAME and AWS_DEFAULT_REGION environment variables. FYI, this ended up being a very trivial env variable issue. Blindly following this comment I initially set AWS_DEFAULT_REGION and AWS_REGION_NAME. But the variable that should be set is AWS_REGION 😅 Doing that, everything works (assuming of course the model is enabled in that region).

I am so sorry. I really thought AWS_REGION was not a valid environment variable. If I get a chance I'll try and track down where that came from in the first place, but it feels like different packages use one of the 3 and so you may need to set all 3 depending on what you're doing.

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.