This page provides instructions on configuring Claude Code through Amazon Bedrock, including setup, IAM configuration, cost tracking, and troubleshooting.

Prerequisites

Before configuring Claude Code with Bedrock, ensure you have:

  • An AWS account with Bedrock access enabled
  • Access to desired Claude models (e.g., Claude Sonnet 4) in Bedrock
  • AWS CLI installed and configured (optional - only needed if you don’t have another mechanism for getting credentials)
  • Appropriate IAM permissions

Setup

1. Enable model access

First, ensure you have access to the required Claude models in your AWS account:

  1. Navigate to the Amazon Bedrock console
  2. Go to Model access in the left navigation
  3. Request access to desired Claude models (e.g., Claude Sonnet 4)
  4. Wait for approval (usually instant for most regions)

2. Configure AWS credentials

Claude Code uses the default AWS SDK credential chain. Set up your credentials using one of these methods:

Claude Code does not currently support dynamic credential management (such as automatically calling aws sts assume-role). You will need to run aws configure, aws sso login, or set the AWS_ environment variables yourself.

Option A: AWS CLI configuration

aws configure

Option B: Environment variables (access key)

export AWS_ACCESS_KEY_ID=your-access-key-id
export AWS_SECRET_ACCESS_KEY=your-secret-access-key
export AWS_SESSION_TOKEN=your-session-token

Option C: Environment variables (SSO profile)

aws sso login --profile=<your-profile-name>

export AWS_PROFILE=your-profile-name

3. Configure Claude Code

Set the following environment variables to enable Bedrock:

# Enable Bedrock integration
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1  # or your preferred region

AWS_REGION is a required environment variable. Claude Code does not read from the .aws config file for this setting.

# Optional: Disable prompt caching if not enabled in your account
export DISABLE_PROMPT_CACHING=1

Contact AWS support to enable prompt caching for reduced costs and higher rate limits. Once enabled, remove the DISABLE_PROMPT_CACHING setting.

4. Model configuration

Claude Code uses these default models for Bedrock:

Model typeDefault value
Primary modelus.anthropic.claude-3-7-sonnet-20250219-v1:0
Small/fast modelus.anthropic.claude-3-5-haiku-20241022-v1:0

To customize models, use one of these methods:

# Using inference profile ID
export ANTHROPIC_MODEL='us.anthropic.claude-opus-4-20250514-v1:0'
export ANTHROPIC_SMALL_FAST_MODEL='us.anthropic.claude-3-5-haiku-20241022-v1:0'

# Using application inference profile ARN
export ANTHROPIC_MODEL='arn:aws:bedrock:us-east-2:your-account-id:application-inference-profile/your-model-id'

IAM configuration

Create an IAM policy with the required permissions for Claude Code.

For details, see Bedrock IAM documentation.

We recommend creating a dedicated AWS account for Claude Code to simplify cost tracking and access control.

Troubleshooting

If you encounter region issues:

  • Check model availability: aws bedrock list-inference-profiles --region your-region
  • Switch to a supported region: export AWS_REGION=us-east-1
  • Consider using inference profiles for cross-region access

If you receive an error “on-demand throughput isn’t supported”:

Additional resources