Skip to content

fix: pass aws_profile to boto3.Session when inferring Bedrock region#1413

Open
tianhaocui wants to merge 1 commit intoanthropics:mainfrom
tianhaocui:fix-bedrock-aws-profile-region
Open

fix: pass aws_profile to boto3.Session when inferring Bedrock region#1413
tianhaocui wants to merge 1 commit intoanthropics:mainfrom
tianhaocui:fix-bedrock-aws-profile-region

Conversation

@tianhaocui
Copy link
Copy Markdown

Fixes #892

Summary

_infer_region() creates a bare boto3.Session() without the profile_name argument, so it never reads the region configured for the specified AWS profile in ~/.aws/config. This causes AnthropicBedrock(aws_profile=...) to default to us-east-1 instead of using the profile's configured region.

Changes

Pass aws_profile through to boto3.Session(profile_name=aws_profile) in _infer_region(), and forward aws_profile from both AnthropicBedrock.__init__ and AsyncAnthropicBedrock.__init__.

4 lines changed across 3 call sites in src/anthropic/lib/bedrock/_client.py.

_infer_region() creates a bare boto3.Session() without the profile_name
argument, so it never reads the region configured for the specified AWS
profile in ~/.aws/config. This causes AnthropicBedrock(aws_profile=...)
to default to us-east-1 instead of using the profile's region.

Pass aws_profile through to boto3.Session(profile_name=aws_profile) so
the region is correctly inferred from the profile configuration.

Fixes anthropics#892
@tianhaocui tianhaocui requested a review from a team as a code owner April 19, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock client failing to detect AWS region correctly can cause cross-region inference to fail

1 participant