Foreword
Important Note: To use AWS Bedrock, you'll need to contact AWS sales to enable access permissions. This method is suitable for enterprise users, not for those with a $20/month budget.
Updated July 25, 2025: Many users reported that the setup wasn't user-friendly enough and requested a "one-click configuration" solution. So we've created new content: Claude Code AWS Bedrock One-Click Configuration Solution.
Overview
To simplify the Claude Code + AWS Bedrock configuration process, we now provide one-click configuration solutions for macOS and Windows, eliminating the need for manual environment variable setup.
Check out the one-click solution here
Background
With recent large-scale Claude account bans, and as an AWS enterprise user with overseas servers, I wondered if I could use AWS APIs to access Claude Code. That's how this guide came about.
If you already have Claude API access through AWS Bedrock and want to use it with the Claude Code command-line tool, this article provides a complete configuration guide.
Understanding AWS Bedrock Model Access Methods
Before starting configuration, it's important to understand the two model access methods in AWS Bedrock:
📋 ON_DEMAND (Pay-as-you-go)
Features:
- ✅ Ready to use: Simple configuration, direct model ID usage
- ✅ Pay per use: Only pay for what you use, no upfront costs
- ✅ No additional applications needed: Works with basic Bedrock access
- ✅ Simple setup: Use basic model IDs directly
Supported model examples:
anthropic.claude-3-5-sonnet-20240620-v1:0
(Claude 3.5 Sonnet v1)anthropic.claude-3-haiku-20240307-v1:0
(Claude 3 Haiku)
🔄 INFERENCE_PROFILE (Inference Profile Mode)
Features:
- ⚙️ Requires additional setup: Uses inference profile IDs
- 🌍 Cross-region load balancing: Automatically distributes requests across regions
- 🚀 Higher availability: Reduces single-region failure impact
- 💰 Potential cost savings: Lower pricing in some cases
Supported model examples:
us.anthropic.claude-sonnet-4-20250514-v1:0
(Claude Sonnet 4)us.anthropic.claude-opus-4-20250514-v1:0
(Claude Opus 4)us.anthropic.claude-3-7-sonnet-20250219-v1:0
(Claude 3.7 Sonnet)
🔍 How to Identify Model Access Methods
Check the inferenceTypesSupported
field in the model list:
// ON_DEMAND only
"inferenceTypesSupported": ["ON_DEMAND"]
// INFERENCE_PROFILE only
"inferenceTypesSupported": ["INFERENCE_PROFILE"]
// Both supported
"inferenceTypesSupported": ["ON_DEMAND", "INFERENCE_PROFILE"]
💡 Recommendations
For beginners:
- Choose models supporting ON_DEMAND (like Claude 3.5 Sonnet v1)
- Simple configuration, immediate availability
For users wanting the latest models:
- Claude 4 series only supports INFERENCE_PROFILE
- Requires inference profiles but gives access to the newest, most powerful models
Model ID Format Comparison:
# ON_DEMAND mode (basic model ID)
anthropic.claude-3-5-sonnet-20240620-v1:0
# INFERENCE_PROFILE mode (inference profile ID)
us.anthropic.claude-sonnet-4-20250514-v1:0 # Note the "us." prefix
Setup Steps
1. Confirm AWS Bedrock Access
- Log into the Amazon Bedrock console
- Select "Model access" from the left navigation
- Ensure you've requested and received access to Claude models (like Claude Sonnet 4)
- Most regions provide instant approval
2. Install Required Tools
Install AWS CLI
On macOS, we recommend using Homebrew:
brew install awscli
Or use the official installer:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
rm AWSCLIV2.pkg
Install Claude Code
Follow the official Anthropic documentation to install Claude Code.
Configuration Steps
Step 1: Configure AWS Credentials
aws configure
Enter your:
- AWS Access Key ID
- AWS Secret Access Key
- Default region name (e.g., us-east-1)
- Default output format (press Enter for default)
Step 2: Verify AWS Connection
# Verify installation
aws --version
# Test connection
aws sts get-caller-identity
Step 3: Check Available Claude Models
# Check basic models
aws bedrock list-foundation-models --region us-east-1 --by-provider anthropic
# Check inference profiles
aws bedrock list-inference-profiles --region us-east-1
Step 4: Configure Claude Code Environment Variables
macOS Configuration
Temporary Configuration (current session only):
# Required environment variables
export CLAUDE_CODE_USE_BEDROCK=1
export DISABLE_PROMPT_CACHING=1
export AWS_REGION=us-east-1
# Optional: specify a particular model (uses default if not set)
export ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0
Permanent Configuration (recommended):
First, check which shell you're using:
echo $SHELL
For Zsh (macOS default):
# Edit .zshrc file
nano ~/.zshrc
# Or add directly with commands
echo 'CLAUDE_CODE_USE_BEDROCK=1' >> ~/.zshrc
echo 'export DISABLE_PROMPT_CACHING=1' >> ~/.zshrc
echo 'export AWS_REGION=us-east-1' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0' >> ~/.zshrc
# Reload configuration
source ~/.zshrc
For Bash:
# Edit .bash_profile file
nano ~/.bash_profile
# Or add directly with commands
echo 'CLAUDE_CODE_USE_BEDROCK=1' >> ~/.bash_profile
echo 'export DISABLE_PROMPT_CACHING=1' >> ~/.bash_profile
echo 'export AWS_REGION=us-east-1' >> ~/.bash_profile
echo 'export ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0' >> ~/.bash_profile
# Reload configuration
source ~/.bash_profile
Windows Configuration
Method 1: System Settings (Recommended)
- Right-click "This PC" → "Properties"
- Click "Advanced system settings"
- In the "System Properties" window, click "Environment Variables"
- In the "User variables" section, click "New" and add each variable:
- Variable name:
ANTHROPIC_PROVIDER
, Variable value:bedrock
- Variable name:
AWS_REGION
, Variable value:us-east-1
- Variable name:
ANTHROPIC_MODEL
, Variable value:us.anthropic.claude-3-7-sonnet-20250219-v1:0
- Variable name:
- Click "OK" to save
- Restart Command Prompt or PowerShell
Method 2: Command Line
In Command Prompt:
setx ANTHROPIC_PROVIDER "bedrock"
setx AWS_REGION "us-east-1"
setx ANTHROPIC_MODEL "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
In PowerShell:
[Environment]::SetEnvironmentVariable("ANTHROPIC_PROVIDER", "bedrock", "User")
[Environment]::SetEnvironmentVariable("AWS_REGION", "us-east-1", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "us.anthropic.claude-3-7-sonnet-20250219-v1:0", "User")
Method 3: Temporary Setup (current session only)
In Command Prompt:
set ANTHROPIC_PROVIDER=bedrock
set AWS_REGION=us-east-1
set ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0
In PowerShell:
$env:ANTHROPIC_PROVIDER="bedrock"
$env:AWS_REGION="us-east-1"
$env:ANTHROPIC_MODEL="us.anthropic.claude-3-7-sonnet-20250219-v1:0"
Verify Environment Variable Configuration
On macOS/Linux:
echo $ANTHROPIC_PROVIDER
echo $AWS_REGION
echo $ANTHROPIC_MODEL
On Windows:
echo %ANTHROPIC_PROVIDER%
echo %AWS_REGION%
echo %ANTHROPIC_MODEL%
Or in PowerShell:
echo $env:ANTHROPIC_PROVIDER
echo $env:AWS_REGION
echo $env:ANTHROPIC_MODEL
Common Issues and Solutions
Issue 1: "provided model identifier is invalid" Error
Cause: Using incorrect model ID format
Wrong example:
# ❌ Incorrect format
apac.anthropic.claude-sonnet-4-20250514-v1:0
Correct approach:
# ✅ Correct format
us.anthropic.claude-3-7-sonnet-20250219-v1:0
# or
anthropic.claude-3-5-sonnet-20241022-v2:0
Issue 2: Region-Related Errors
If you encounter issues in a particular region, try switching to us-east-1:
export AWS_REGION=us-east-1
Issue 3: Permission Errors
Ensure your AWS user/role has appropriate Bedrock IAM permissions. Consider creating a dedicated AWS account to simplify cost tracking and access control.
Issue 4: Claude Code Asks for Claude Account Login Despite AWS Bedrock Configuration
Make sure you have the required environment variables for AWS Bedrock:
# Required environment variables
export CLAUDE_CODE_USE_BEDROCK=1
export DISABLE_PROMPT_CACHING=1
export AWS_REGION=us-east-1
# Optional: specify particular model (uses default if not set)
export ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0
Key points:
- ✅
CLAUDE_CODE_USE_BEDROCK=1
- Tells Claude Code to use Bedrock - ✅
DISABLE_PROMPT_CACHING=1
- Disables prompt caching (Bedrock doesn't support it) - ✅
AWS_REGION=us-east-1
- Sets AWS region - ✅
ANTHROPIC_MODEL
- Specifies model (optional)
Default Model Configuration
Claude Code uses these default models in Bedrock:
Model Type | Default Value |
---|---|
Primary model | us.anthropic.claude-3-7-sonnet-20250219-v1:0 |
Small/fast model | us.anthropic.claude-3-5-haiku-20241022-v1:0 |
Verify Configuration
After completing all configuration, run these commands to verify:
# Verify environment variable settings
echo $ANTHROPIC_PROVIDER
echo $AWS_REGION
echo $ANTHROPIC_MODEL
# Verify Claude Code is working properly
claude --help
# Try a simple conversation
claude "Hello, how are you?"
⚠️ Important Note: Environment Variable Timing
Temporary settings (export commands):
- ✅ Take effect immediately in current terminal session
- ✅ No need to reopen terminal
- ❌ Settings lost when terminal is closed
Permanent settings (modifying config files):
- ✅ Settings are persistently saved
- ❌ Current terminal needs
source ~/.zshrc
to take effect - ✅ New terminals automatically load configuration
Verification recommendations:
- After using export commands, verify directly in current terminal, no restart needed
- After modifying config files, run
source ~/.zshrc
or reopen terminal
Cost Optimization Tips
- Enable prompt caching: Contact AWS support to enable prompt caching for lower costs and higher rate limits
- Remove cache disable setting: After enabling, delete the
DISABLE_PROMPT_CACHING=true
environment variable - Use dedicated account: Consider creating a dedicated AWS account for Claude Code for better cost tracking
Summary
Following these steps, you can successfully configure Claude Code to use Claude models on AWS Bedrock. Key points:
- ✅ AWS CLI handles credential management
- ✅ Environment variable
AWS_REGION
is required (Claude Code doesn't read AWS config files) - ✅ Use correct model ID format
- ✅ Ensure proper Bedrock access and IAM configuration
This approach avoids exposing sensitive access keys in environment variables while fully utilizing Claude services on AWS Bedrock.
This article is compiled based on Anthropic's official documentation and actual configuration experience. For specific issues, please refer to the latest official documentation.
References
- Claude Code on Amazon Bedrock - Anthropic
- Claude Code Bedrock Model Configuration Error - GitHub Issue