Claude Code on Amazon Bedrock and Vertex AI: setup and errors
Run Claude Code on Amazon Bedrock or Google Vertex AI: env vars, SSO or API key, model pinning, IAM policy, what's unavailable, billing, and the common errors.
Set CLAUDE_CODE_USE_BEDROCK=1, give Claude Code AWS credentials through the normal AWS chain (an SSO profile in AWS_PROFILE, aws login or access keys) or a Bedrock API key in AWS_BEARER_TOKEN_BEDROCK, set AWS_REGION if your profile has none, and pin your models to Bedrock inference profile IDs such as us.anthropic.claude-sonnet-4-6. Or run claude, pick 3rd-party platform then Amazon Bedrock, and the wizard writes all of it for you. Your identity needs bedrock:InvokeModel and its streaming sibling. AWS bills you per token, your Claude plan does not apply, and web search, fast mode, Remote Control and the other claude.ai features are not available. For Google Cloud, the same shape uses CLAUDE_CODE_USE_VERTEX=1, CLOUD_ML_REGION and ANTHROPIC_VERTEX_PROJECT_ID.
On the AWS side first
Claude models on Bedrock are switched on per account rather than requested one by one. In AWS’s model access page, as of November 2026, access is enabled by default if the identity making the first call has the AWS Marketplace permissions, and the account has a valid payment method for Marketplace purchases.
Then there is a one-time use case form, which you fill in by opening the Model catalog in the Bedrock console and choosing an Anthropic model. The two vendors’ docs disagree about it as of November 2026. AWS says only Anthropic models earlier than Claude Opus 4.7 need it (Sonnet 4.6, Opus 4.6, Haiku 4.5 and the Claude 3.x models), that access is granted as soon as the form is submitted “in most cases”, and that the agreement can instead sit pending, with calls returning AccessDeniedException until it clears. Anthropic’s Bedrock page asks you to submit it before you first invoke any Anthropic model and says access is granted immediately. Submitting it once covers both readings. Both agree it is once per account, and that under AWS Organizations a submission from the management account covers the child accounts; AWS adds that opt-in regions need it again.
The first call to a model also starts its Marketplace subscription in the background. AWS says that takes up to 15 minutes, during which calls may succeed; if a prerequisite such as the Marketplace permissions is missing, the subscription fails and later calls return AccessDeniedException. To see where a model stands (AWS CLI 2.27.42 or later):
# AWS's example model ID; use the one on your model's model card
aws bedrock get-foundation-model-availability --model-id anthropic.claude-sonnet-4-20250514-v1:0
# agreementAvailability.status: AVAILABLE, PENDING, NOT_AVAILABLE or ERRORCopiedThe quick route: the setup wizard
Start claude, choose 3rd-party platform at the login prompt, then Amazon Bedrock. If you are already signed in, type /setup-bedrock in full: the command menu hides it until CLAUDE_CODE_USE_BEDROCK=1 is set. The wizard asks how you authenticate (a profile it finds in ~/.aws, a Bedrock API key, an access key and secret, or credentials already in your environment), asks for a region, checks which Claude models your account can call, and lets you pin them. It saves the result to the env block of ~/.claude/settings.json (or $CLAUDE_CONFIG_DIR/settings.json), so nothing needs exporting. Run /setup-bedrock again later to change any of it.
If you chose a key rather than a profile, look at what landed in that file and keep it readable by you alone (chmod 600 ~/.claude/settings.json). It is your user file in your home directory, not a project file, so it stays out of a repository unless you sync your dotfiles to one.
Manual setup with environment variables
For CI, a server, or a scripted rollout, set the variables yourself. Claude Code uses the standard AWS SDK credential chain, so anything that already works for the AWS CLI on the machine works here, including an EC2 instance profile or ECS task role, which need no further setup.
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1 # optional if your profile sets a region
# credentials: pick one
aws sso login --profile my-profile # IAM Identity Center, then:
export AWS_PROFILE=my-profile
aws login # console credentials, AWS CLI 2.32.0+, up to 12 hours
claudeCopiedThe other two routes put a secret in your environment, so treat them with more care:
- Access keys:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYand, for temporary credentials,AWS_SESSION_TOKEN. AWS warns against using an IAM user’s access keys when you develop purpose-built software or work with real data; prefer SSO oraws login. If you must use them, letaws configurestore them in~/.aws/credentialsrather than typing them on a command line, where they land in your shell history. - A Bedrock API key:
AWS_BEARER_TOKEN_BEDROCK. When it is set, Claude Code uses the key and ignores every other AWS credential on the machine. AWS’s API key docs give short-term keys a life of up to 12 hours and only in the region that generated them, and recommend them for production; long-term keys, which create an IAM user behind them, are “for exploration only”. Keep a key in a file only you can read, written with an editor rather than anechothat lands in your shell history, and load it into the shell instead of pasting it into scripts or a committed.env:
# ~/.config/bedrock-key holds only the key; chmod 600 it
export AWS_BEARER_TOKEN_BEDROCK="$(cat ~/.config/bedrock-key)"CopiedA leaked long-term key is deactivated, reset or deleted from the Bedrock console’s API keys page. To keep settings such as AWS_PROFILE out of other processes’ environment, put them in the env block of your user settings instead of your shell profile; Claude Code’s settings.json covers which file wins. A cloud provider flag outranks every other credential, so a claude.ai login or an ANTHROPIC_API_KEY on the same machine is ignored while CLAUDE_CODE_USE_BEDROCK is set, and /logout is unavailable on Bedrock.
Run /status inside Claude Code to confirm: it shows the resolved region and, when the region came from your AWS config files or the us-east-1 fallback, where it came from.
Region and inference profile IDs
Claude Code takes the region from AWS_REGION, then AWS_DEFAULT_REGION, then the active profile’s region, then falls back to us-east-1. It calls Claude through cross-region inference profiles, whose IDs carry a geography prefix it derives from your region:
| Region | Prefix | Example ID |
|---|---|---|
us-gov-* | us-gov. | us-gov.anthropic.… |
us-* | us. | us.anthropic.claude-sonnet-4-6 |
eu-* | eu. | eu.anthropic.claude-opus-5-5 |
ap-* | apac. | apac.anthropic.… |
Anything else | global. | global.anthropic.claude-opus-5-5 |
To prefer another prefix while keeping Claude Code’s default models, set ANTHROPIC_BEDROCK_REGION_PREFIX to us, eu, apac, jp, au or global. To see which profiles your account has in a region:
aws bedrock list-inference-profiles --region eu-west-1CopiedPin your models
Without pins, as of November 2026, the opus alias and the default model on Bedrock are Opus 5.5 (for example us.anthropic.claude-opus-5-5), and sonnet is Sonnet 4.5, which also carries background jobs such as session titles because Haiku may not be enabled in every account. Anthropic’s page puts the cost plainly: “if you don’t pin a primary model, you’re billed at the Opus rate.” Pin each alias to an ID your account can call:
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'
# or start every session on one model
export ANTHROPIC_MODEL='us.anthropic.claude-sonnet-4-6'
# an application inference profile works too
export ANTHROPIC_MODEL='arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/your-profile'CopiedAt startup Claude Code checks that its models are callable. An unpinned default your account lacks falls back to an earlier or lower model for that session, with a notice. If a model is turned off mid-session you see a line starting Switched to <fallback> because <model> is not available; on a pinned model the request fails instead, and /model then s on a model you can use keeps you working. The aliases, modelOverrides and the 1M-token context (on by default for Fable, Sonnet 5 and later and Opus 4.7 and later) are covered in Claude Code models.
The IAM permissions
This is the policy from Anthropic’s Bedrock page. The Marketplace statement only matters for the first call that enables a model in the account; narrow the Resource list to specific profile ARNs if you want it tighter.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowModelAndInferenceProfileAccess",
"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/*"
]
},
{
"Sid": "AllowMarketplaceSubscription",
"Effect": "Allow",
"Action": [
"aws-marketplace:ViewSubscriptions",
"aws-marketplace:Subscribe"
],
"Resource": "*",
"Condition": {
"StringEquals": { "aws:CalledViaLast": "bedrock.amazonaws.com" }
}
}
]
}CopiedListInferenceProfiles lets Claude Code discover which profiles you have, and without it the region prefix is applied blind. Anthropic also suggests a dedicated AWS account for Claude Code, which keeps its bill and its access separate from everything else.
Credentials on a long run
SSO sessions, aws login and short-term API keys all expire, which matters for a session left working overnight. Claude Code keeps resolved credentials in memory until five minutes before they expire and refetches from the chain after a credential error, which covers a chain that can refresh itself. For SSO, add a refresh command to ~/.claude/settings.json; Claude Code runs it only when the credentials have actually expired, then retries:
{
"awsAuthRefresh": "aws sso login --profile my-profile",
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"AWS_PROFILE": "my-profile",
"AWS_REGION": "us-east-1"
}
}CopiedThe command cannot take keyboard input, so it suits browser sign-in flows that print a URL. On a headless server nobody is there to open that URL, so on EC2 an instance profile, or elsewhere a fresh aws sso login before you start, is the dependable choice. If sign-in tabs keep opening behind a corporate proxy, remove awsAuthRefresh and sign in by hand first.
What is not available on Bedrock
The CLI, the VS Code and JetBrains extensions, subagents, hooks, skills, MCP servers, plugins and the Agent SDK all work on Bedrock. Per Anthropic’s feature availability page, as of November 2026, these do not:
- Web search. The WebSearch tool is not offered. WebFetch on a specific URL still works.
- Fast mode.
/fastrepliesFast mode is not available on this provider(what fast mode is and where it does run: Claude Code fast mode). - Everything that needs a claude.ai sign-in: cloud sessions and Claude Code on mobile, Claude Code Desktop (see below), cloud scheduled tasks (
/schedule; use/loopinstead), Ultrareview, Code Review, PR Steward, Claude Approvals, Remote Control, the Chrome extension, computer use, Artifacts and voice dictation. - Also missing: the Advisor, Channels, the analytics dashboard, server-managed settings, and the
/design-syncand/importcommands. - Partly there: auto mode only on Sonnet 5 or later, Opus 4.7 or later, Haiku 5.5 and Fable; Desktop only via Claude Desktop on 3P, its separate third-party setup; cross-session messaging only between your sessions on the same machine; Zero Data Retention subject to your AWS agreement.
Error reporting and telemetry to Anthropic are off by default on Bedrock.
What it costs
On Bedrock, Claude Code is billed per token to your AWS account at Bedrock’s prices, which you find on AWS’s Bedrock pricing page. A Pro, Max or Team plan does nothing here, and spend controls live in AWS’s billing console rather than in Claude. The dollar figure in /usage is an estimate Claude Code works out locally at list price, so the AWS bill is the real number. For how token use grows and how to keep it down, see what Claude Code costs.
Common Bedrock errors
The one you will meet most:
AWS authentication failed · ... · if credentials are current, check AWS permissions and model access · API Error: 403CopiedBedrock answers both an expired token and a missing permission with a 403, and Claude Code cannot tell them apart. Refresh your sign-in first; if that changes nothing, run aws sts get-caller-identity to see which identity is actually making the calls, check the policy above is attached to it, and check the model is enabled for that account and region.
| You see | What it means |
|---|---|
Could not load AWS credentials | Nothing in the chain produced credentials, often an expired SSO session. Sign in again and retry. |
AWS default-chain credential resolve timed out | The chain hung for 60 seconds, usually a credential_process waiting for input or an instance metadata service that never answers. Test with aws sts get-caller-identity; raise the limit with CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS only for a slow but working sign-in. |
on-demand throughput isn’t supported | Specify the model as an inference profile ID, with its prefix. |
A 400 error | One cause: without ListInferenceProfiles Claude Code applies its region prefix unchecked, and your account has no profiles with that prefix. Set ANTHROPIC_BEDROCK_REGION_PREFIX or pin full IDs. |
AccessDeniedException right after setup | The model’s subscription or use case form is still pending. Check with get-foundation-model-availability. |
Bedrock also has a second endpoint, Mantle, that serves Claude in the native Anthropic API shape. It is enabled with CLAUDE_CODE_USE_MANTLE=1, needs its own bedrock-mantle: IAM actions, and takes IDs such as anthropic.claude-haiku-4-5; the us. profile IDs return a 400 there.
Google Cloud: Agent Platform, formerly Vertex AI
Google renamed Vertex AI to Agent Platform, but the variables and the login prompt still say Vertex. Enable the API, then turn on the Claude models you want in Model Garden, which Anthropic’s Agent Platform page says may take 24 to 48 hours to approve:
gcloud config set project YOUR-PROJECT-ID
gcloud services enable aiplatform.googleapis.com
gcloud auth application-default login
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=global # or us, eu, or a region such as us-east5
export ANTHROPIC_VERTEX_PROJECT_ID=YOUR-PROJECT-ID
claudeCopiedOr pick 3rd-party platform, then Google Vertex AI at the login prompt, and use /setup-vertex to change it later. It accepts Application Default Credentials, a service account key file (in GOOGLE_APPLICATION_CREDENTIALS; keep the file outside any repository and readable by you alone) or credentials already in your environment. Requests go to ANTHROPIC_VERTEX_PROJECT_ID even if GOOGLE_CLOUD_PROJECT or the key file names another project. /status should show API provider as Google Vertex AI with your project and region.
- Permissions:
roles/aiplatform.user, or a custom role withaiplatform.endpoints.predict. - Models: the defaults are
claude-opus-5-5and, for background jobs,claude-sonnet-4-5@20250929. IDs here have no prefix, for exampleANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-5'orclaude-haiku-4-5@20251001. - Regions: not every model is on the global endpoint. With
CLOUD_ML_REGION=global, send one model elsewhere with its own variable, such asVERTEX_REGION_CLAUDE_HAIKU_4_5=us-east5. Unset, the region falls back tous-east5. - Long runs: set
"gcpAuthRefresh": "gcloud auth application-default login"in settings and Claude Code runs it when the credentials expire, waiting up to three minutes for you to finish in the browser. - Features: the claude.ai-only list above applies here too, as do the missing Advisor, Channels, analytics dashboard, server-managed settings and
/design-syncand/importcommands. Unlike Bedrock, web search works on Opus 4, Sonnet 4, Haiku 4.5 and later, and fast mode is offered on Fable 5.2 in theglobal,usandeuregions (Claude Code v2.1.322 or later), or standard speed if Agent Platform refuses it; in another region/fastsaysFast mode needs Vertex region global, us or eu. - Billing: per token to your Google Cloud account, seen in GCP Billing.
| You see | Do this |
|---|---|
Could not load the default credentials | Run gcloud auth application-default login, or point GOOGLE_APPLICATION_CREDENTIALS at a key file. |
Google Cloud authentication failed (403) | The identity lacks the role, or the model is not enabled for the project in Model Garden. |
Google Cloud credentials expired or invalid (401) | Sign in again; gcloud auth application-default print-access-token confirms the identity outside Claude Code. |
404 model not found | The model is not enabled, or not served at that location. Some are only on global, us or eu. |
429 | Quota. Check both your main and background model exist in the region, try CLOUD_ML_REGION=global, or ask Google Cloud for more quota. |
If you would rather pay Anthropic directly than a cloud, use a Console API key, or a plan through the normal login, which is what the claude.ai features this page lists as missing need.