Skip to content
,

How to Use Claude Code With Amazon Bedrock (2026): Setup, IAM and Fixes

7–10 minutes
Woman in a lab coat in a glass-walled office holding a tablet with an AMAZON BEDROCK card, hook Claude Code on Bedrock

Many companies already pay for AWS and want Claude Code to bill through it, stay inside their AWS account and follow their IAM rules. Claude Code supports that natively. It can send every request to Claude models on Amazon Bedrock instead of Anthropic’s API.

This guide shows you how to set it up from start to finish.

You will enable the models in AWS, use the new /setup-bedrock wizard or environment variables, pick credentials (SSO, access keys, aws login or a Bedrock API key), pin model versions, write the IAM policy, add guardrails, try the Mantle endpoint, and fix the errors people hit most. It follows Anthropic’s Claude Code documentation as of December 2026.

TL;DR

  • Easiest: run claude, pick 3rd-party platform → Amazon Bedrock, or run /setup-bedrock later.
  • Manual: export CLAUDE_CODE_USE_BEDROCK=1 and export AWS_REGION=us-east-1, with AWS credentials in the default chain.
  • Enable models first in the Bedrock console Model catalog by submitting the Anthropic use case form once per account.
  • Pin models for teams with ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL.
  • IAM needs bedrock:InvokeModel, InvokeModelWithResponseStream, ListInferenceProfiles and GetInferenceProfile.
  • Not available on Bedrock: the WebSearch tool and /logout.

Why Use Claude Code on Bedrock

  • One bill. Usage appears on your AWS invoice and counts toward AWS commitments.
  • Your security model. Access is controlled with IAM, SSO and AWS Organizations, and traffic stays with AWS.
  • Enterprise controls. Guardrails, service tiers, inference profiles and CloudWatch-style monitoring.

The trade-off: a few features tied to Anthropic accounts are missing. The WebSearch tool does not run on Bedrock, /logout is unavailable because AWS handles sign-in, and new models can reach Bedrock a little later.

If you are a solo developer with a Claude Pro or Max plan, signing in normally is simpler; see Claude Code pricing to compare.

Prerequisites

  • An AWS account with Amazon Bedrock enabled
  • Access to the Claude models you want in Bedrock
  • IAM permissions for Bedrock (policy below)
  • The AWS CLI, only if you need it to get credentials
  • Claude Code installed; follow how to install Claude Code if needed

Enable Anthropic Models in AWS

Before the first request, AWS needs your use case details. You do this once per account.

  1. Open the Amazon Bedrock console and go to Model catalog.
  2. Select an Anthropic model, such as a Claude Sonnet or Opus model.
  3. Complete the use case form. Access is granted right after you submit it.
  4. For AWS Organizations, submit once from the management account with the PutUseCaseForModelAccess API (needs bedrock:PutUseCaseForModelAccess). Approval extends to child accounts.

Quick Setup With the Wizard

If you already have AWS credentials, the built-in wizard is the fastest path.

  1. Run claude. At the login prompt, choose 3rd-party platform, then Amazon Bedrock. Already signed in? Run /setup-bedrock.
  2. Pick how you authenticate: an AWS profile from ~/.aws, a Bedrock API key, an access key and secret, or credentials already in your environment.
  3. Choose your region. The wizard checks which Claude models your account can invoke.
  4. Pin models when offered, including the 1M context option.
  5. Done. The wizard saves everything to the env block of ~/.claude/settings.json (or $CLAUDE_CONFIG_DIR/settings.json).

Run /setup-bedrock any time to change credentials, region or model pins. Run /status to see the provider and resolved region.

Choose Your AWS Credentials

Claude Code uses the standard AWS SDK credential chain, so EC2 instance profiles and ECS task roles work with no setup. Otherwise pick one:

Method Command Best for
SSO profile aws sso login --profile=dev then export AWS_PROFILE=dev Companies using IAM Identity Center
Console sign-in aws login (AWS CLI 2.32.0+) Personal AWS accounts; sessions last up to 12 hours
Bedrock API key export AWS_BEARER_TOKEN_BEDROCK=... Quick tests; works only for Bedrock
Access key aws configure or AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY Fallback; AWS warns against long-lived IAM user keys

Bedrock API keys come in two types. Short-term keys last up to 12 hours and AWS prefers them; long-term keys are for exploration only.

Auto-refresh expired SSO credentials

Add awsAuthRefresh to your settings so Claude Code re-runs your login when credentials expire:

{
  "awsAuthRefresh": "aws sso login --profile myprofile",
  "env": { "AWS_PROFILE": "myprofile" }
}

Claude Code first calls STS GetCallerIdentity to confirm the credentials really expired. If your setup needs cross-account credentials, use awsCredentialExport with a command that prints credentials as JSON instead.

Credentials are cached in memory until five minutes before they expire, or one hour if they carry no expiry. Set CLAUDE_CODE_SKIP_AWS_CRED_CACHE=1 to resolve them on every request.

Manual Setup With Environment Variables

For CI pipelines and scripted rollouts, skip the wizard and set variables:

export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1
# optional: custom endpoint or gateway
# export ANTHROPIC_BEDROCK_BASE_URL=https://bedrock-runtime.us-east-1.amazonaws.com

Region resolution goes AWS_REGION, then AWS_DEFAULT_REGION, then the region on your active AWS profile, then us-east-1. You only need AWS_REGION if your profile lacks one.

Put these in the env block of a settings file so they do not leak to other processes. Our Claude Code settings guide explains the file locations, and the Claude Code environment variables guide lists related variables.

Running Claude in GitHub Actions on Bedrock? See our Claude Code GitHub Actions setup.

Pin Model Versions

Without pins, aliases like opus and sonnet resolve to Claude Code’s built-in Bedrock defaults. Those can lag the newest release or point to a model your account cannot use. Pin exact IDs before rolling out to a team:

export ANTHROPIC_DEFAULT_OPUS_MODEL='us.anthropic.claude-opus-4-8'
export ANTHROPIC_DEFAULT_SONNET_MODEL='us.anthropic.claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='us.anthropic.claude-haiku-4-5-20251001-v1:0'

Current defaults when nothing is pinned: the primary model is Opus 5.5 (for example us.anthropic.claude-opus-5-5), and the small, fast background model is Sonnet 4.5 on the Invoke API. Set ANTHROPIC_DEFAULT_HAIKU_MODEL to use Haiku for background tasks.

Region prefixes

AWS region Prefix
us-* us.
eu-* eu.
ap-* apac.
us-gov-* us-gov.
Others global.

To keep the defaults but change only the prefix, set ANTHROPIC_BEDROCK_REGION_PREFIX=eu or global. You can also point ANTHROPIC_MODEL at an application inference profile ARN for cost tracking. For more on switching models in a session, see how to change the model in Claude Code.

If a pinned model is unavailable at startup, Claude Code falls back to an earlier model your account can use. Set CLAUDE_CODE_DISABLE_MODEL_ACCESS_FALLBACK=1 if you would rather it fail.

IAM Policy

Attach a policy like this to the users or roles that run Claude Code:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "bedrock:InvokeModel",
      "bedrock:InvokeModelWithResponseStream",
      "bedrock:ListInferenceProfiles",
      "bedrock:GetInferenceProfile"
    ],
    "Resource": [
      "arn:aws:bedrock:*:*:inference-profile/*",
      "arn:aws:bedrock:*:*:application-inference-profile/*",
      "arn:aws:bedrock:*:*:foundation-model/*"
    ]
  }]
}

ListInferenceProfiles lets Claude Code discover which models you can use, and GetInferenceProfile resolves application profile ARNs to the right model. Tighten the resources to specific models and regions for production.

Guardrails, Service Tiers and 1M Context

Amazon Bedrock Guardrails

Create and publish a guardrail in the Bedrock console, then send its headers from your settings:

{
  "env": {
    "ANTHROPIC_CUSTOM_HEADERS": "X-Amzn-Bedrock-GuardrailIdentifier: your-guardrail-id\nX-Amzn-Bedrock-GuardrailVersion: 1"
  }
}

Service tiers

Trade cost against latency with ANTHROPIC_BEDROCK_SERVICE_TIER set to default, flex or priority.

1M token context

Fable models, Sonnet 5 and later, and Opus 4.7 and later use the 1M context window by default on Bedrock. Opus 4.6 and Sonnet 4.6 need the [1m] suffix on the model ID. More in our Claude Code context window guide.

Prompt caching

Caching is on by default. Set ENABLE_PROMPT_CACHING_1H=1 for a one-hour cache, or DISABLE_PROMPT_CACHING=1 to turn it off.

The Mantle Endpoint

Mantle is a Bedrock endpoint that serves Claude through the native Anthropic API shape instead of the Bedrock Invoke API. It uses the same AWS credentials.

  • Enable it with export CLAUDE_CODE_USE_MANTLE=1. /status shows Amazon Bedrock (Mantle).
  • Model IDs look like anthropic.claude-sonnet-5, with no region prefix or version suffix.
  • IAM uses separate actions: bedrock-mantle:CreateInference and bedrock-mantle:CountTokens.
  • Set both CLAUDE_CODE_USE_BEDROCK=1 and CLAUDE_CODE_USE_MANTLE=1 to use both in one session.

Troubleshooting

“on-demand throughput isn’t supported”

Use an inference profile ID such as us.anthropic.claude-sonnet-4-6 instead of a bare model ID.

Model not available in your region

Check with aws bedrock list-inference-profiles --region your-region, switch to a supported region, or use a global. profile.

Browser SSO tabs keep opening

A VPN or TLS-inspecting proxy is interrupting the SSO flow. Remove awsAuthRefresh from settings and sign in manually.

Certificate errors behind a corporate proxy

Add your corporate root certificate to the OS trust store or a NODE_EXTRA_CA_CERTS bundle. Current versions apply it to all AWS calls.

“Bedrock streaming response has content-type”

A gateway is rewriting the stream’s Content-Type. Configure it to pass the InvokeModelWithResponseStream body and headers unchanged.

AWS default-chain credential resolve timed out

A step in your credential chain, such as a credential_process helper, is waiting for input. Fix the helper or use another method.

For general problems, see Claude Code not working.

FAQ

Can I use Claude Code with Amazon Bedrock?

Yes. Set CLAUDE_CODE_USE_BEDROCK=1 with AWS credentials, or use the /setup-bedrock wizard.

Do I need a Claude subscription to use Claude Code on Bedrock?

No. Usage is billed by AWS at Bedrock prices. You only need AWS access to the Claude models.

Which models does Claude Code use on Bedrock by default?

Opus 5.5 as the primary model and Sonnet 4.5 for background tasks, unless you pin other models.

Does web search work on Bedrock?

No. The built-in WebSearch tool is not available on Amazon Bedrock.

How do I check that Claude Code is using Bedrock?

Run /status. It shows the provider and the resolved region.

What is the Mantle endpoint?

A Bedrock endpoint that speaks the native Anthropic API. Enable it with CLAUDE_CODE_USE_MANTLE=1 and use anthropic. model IDs.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman in a lab coat in a glass-walled office holding a tablet with an AMAZON BEDROCK card, hook Claude Code on Bedrock