The Claude Agent SDK — the library form of Claude Code's agent loop — doesn't care where its model tokens come from. Set CLAUDE_CODE_USE_BEDROCK=1 and every model call the loop makes routes to Amazon Bedrock in your AWS account, authenticated with AWS credentials rather than an Anthropic API key. The agent still runs in your process with local JSONL session state (see Agent SDK vs. Managed Agents); only the inference endpoint moves. This shares configuration with Claude Code itself, which also offers a /setup-bedrock login wizard and, from v2.1.94, a startup model check.
How credentials and region resolve
There is no Claude-specific auth. The SDK uses the default AWS SDK credential chain — CLI configuration, access keys, an SSO profile, aws login, or a Bedrock API key supplied as AWS_BEARER_TOKEN_BEDROCK. Whatever your other AWS workloads use will work here, which is precisely the appeal for enterprises: agent traffic is authorized, audited, and billed like any other Bedrock workload, with no Anthropic API key to provision or rotate. Region resolution (v2.1.172+) follows a documented order: AWS_REGION → AWS_DEFAULT_REGION → the active AWS profile's region → fallback us-east-1. Worth pinning explicitly in containers and CI runners, where a missing region variable silently lands you in us-east-1 — a confusing failure if your model access or inference profiles live elsewhere.
Model selection is also env-var driven: ANTHROPIC_MODEL plus ANTHROPIC_DEFAULT_OPUS_MODEL / ANTHROPIC_DEFAULT_SONNET_MODEL / ANTHROPIC_DEFAULT_HAIKU_MODEL, taking cross-region inference profile IDs (e.g. us.anthropic.claude-opus-4-8, with a us-gov. prefix in GovCloud) or application inference profile ARNs; a modelOverrides setting maps model versions to per-version ARNs for stricter pinning.
IAM: the four actions you need
The documented policy grants bedrock:InvokeModel, bedrock:InvokeModelWithResponseStream, bedrock:ListInferenceProfiles, and bedrock:GetInferenceProfile, scoped to inference-profile, application-inference-profile, and foundation-model ARNs, plus a conditional aws-marketplace:Subscribe if roles will subscribe to models themselves. Note the pair of profile-related actions: because model pinning uses inference profiles, the agent needs to list and read them, not just invoke. General setup guidance is in Bedrock IAM setup.
The Mantle flag: Bedrock's native Anthropic API shape
Bedrock has two serving surfaces for Claude: the classic Invoke API and the newer Mantle endpoint, which speaks the native Anthropic API shape with dateless anthropic.-prefixed model IDs like anthropic.claude-sonnet-5. The SDK exposes this as a second flag:
CLAUDE_CODE_USE_MANTLE=1routes to the Mantle endpoint (requires Claude Code v2.1.94+).- Setting both
CLAUDE_CODE_USE_BEDROCKandCLAUDE_CODE_USE_MANTLEruns both endpoints in one session, routing each request by its model-ID format. - For LLM-gateway setups,
CLAUDE_CODE_SKIP_MANTLE_AUTH=1plusANTHROPIC_BEDROCK_MANTLE_BASE_URLlets a proxy own authentication.
Mantle also matters for context size: on Bedrock, Sonnet 5 is served through Mantle and always runs with the 1M-token window, while Opus 4.6+ and Sonnet 4.6 enable 1M context via a [1m] suffix on the model ID. For long-running agent sessions — where the loop's accumulated history is the main consumer of context — that difference decides how long an agent can work before compaction kicks in. Background on the endpoint itself is in the Mantle endpoint explainer.
Gaps and extras on Bedrock
| Behavior | On Bedrock |
|---|---|
| WebSearch tool | Not available — Bedrock has no server-side web search; see workarounds |
/logout | Unavailable; authentication is AWS-side |
| API surface | Uses the Bedrock Invoke API; the Converse API is not supported |
| Prompt caching | Automatic; DISABLE_PROMPT_CACHING=1 to disable, ENABLE_PROMPT_CACHING_1H=1 for 1-hour TTL (billed higher than the 5-minute default) |
| Service tier | ANTHROPIC_BEDROCK_SERVICE_TIER = default/flex/priority, sent as X-Amzn-Bedrock-Service-Tier |
| Guardrails | Attach via ANTHROPIC_CUSTOM_HEADERS with X-Amzn-Bedrock-GuardrailIdentifier / X-Amzn-Bedrock-GuardrailVersion |
Where to go next
Compare the sibling setups on Google Cloud and Microsoft Foundry, or dig into Bedrock's model-ID prefix rules and cross-region inference.