Learn about configuring Claude Code through Amazon Bedrock, including setup, IAM configuration, and troubleshooting.
awsAuthRefresh
and/or awsCredentialExport
commands to obtain new credentials before retrying the request.
awsAuthRefresh
: Use this for commands that modify the .aws
directory (e.g., updating credentials, SSO cache, or config files). Output is shown to the user (but user input is not supported), making it suitable for browser-based authentication flows where the CLI displays a code to enter in the browser.
awsCredentialExport
: Only use this if you cannot modify .aws
and must directly return credentials. Output is captured silently (not shown to the user). The command must output JSON in this format:
AWS_REGION
is a required environment variable. Claude Code does not read from the .aws
config file for this setting./login
and /logout
commands are disabled since authentication is handled through AWS credentials.AWS_PROFILE
that you don’t want to leak to other processes. See Settings for more information.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 |
CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096
: Bedrock’s burndown throttling logic sets a minimum of 4096 tokens as the max_token penalty. Setting this lower won’t reduce costs but may cut off long tool uses, causing the Claude Code agent loop to fail persistently. Claude Code typically uses less than 4096 output tokens without extended thinking, but may need this headroom for tasks involving significant file creation or Write tool usage.
MAX_THINKING_TOKENS=1024
: This provides space for extended thinking without cutting off tool use responses, while still maintaining focused reasoning chains. This balance helps prevent trajectory changes that aren’t always helpful for coding tasks specifically.
aws bedrock list-inference-profiles --region your-region
export AWS_REGION=us-east-1