AI agents · OpenClaw · self-hosting · automation

Quick Answer

How to Use Amazon Ergo in Claude Code, Codex and OpenCode

Published:

The short answer

OpenCode and Codex CLI talk to Amazon Ergo on Bedrock directly; Claude Code needs a local LiteLLM proxy. All three use the same prerequisites: a Bedrock API key in AWS_BEARER_TOKEN_BEDROCK, an IAM policy that allows the Ergo inference profiles, and the model ID global.amazon.ergo-1.0 (or us.amazon.ergo-1.0 to keep traffic in US Regions). Ergo launched December 1, 2026 at $1/$3 per million tokens; background is in what is Amazon Ergo.

Which tool to pick

OpenCodeCodex CLIClaude CodeKiro
ConnectionDirect, Chat CompletionsDirect, Responses APILiteLLM proxy → Responses APINative
Extra softwareNoneNoneuv + LiteLLMNone
Config file~/.config/opencode/opencode.json~/.codex/config.tomllitellm.yaml + launcher script—
GotchaKeep limit.output near what you need (it reserves quota)Must set web_search = "disabled" and AWS_REGIONSettings env block can override the launcher—
Pick whenYou want the simplest open-source setupYou already use CodexYour team’s workflow lives in Claude CodeYou’re on AWS’s own IDE

Step 1: Prerequisites (all tools)

  1. Create a long-term API key in the Bedrock console (API keys → Create long-term key) and export it as AWS_BEARER_TOKEN_BEDROCK. Short-term keys from aws-bedrock-token-generator also work but expire.
  2. Attach an IAM policy allowing bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream on inference-profile/us.amazon.ergo-1.0, inference-profile/global.amazon.ergo-1.0 and foundation-model/amazon.ergo-1.0.
  3. Use the endpoint https://bedrock-runtime.<region>.amazonaws.com/openai/v1 (AWS’s examples use us-west-2).

Step 2a: OpenCode

Add a provider to ~/.config/opencode/opencode.json using the @ai-sdk/openai-compatible package, with baseURL set to the Bedrock OpenAI endpoint, apiKey set to {env:AWS_BEARER_TOKEN_BEDROCK}, and a model entry global.amazon.ergo-1.0 with limit context 1,048,568 and output 131,072 and reasoningEffort: "medium". Run opencode and switch with /models.

Step 2b: Codex CLI

In ~/.codex/config.toml set model = "global.amazon.ergo-1.0", model_provider = "bedrock-runtime", model_reasoning_effort = "medium", web_search = "disabled" (Bedrock doesn’t support Codex’s server-side web search) and model_context_window = 1048568. Define [model_providers.bedrock-runtime] with the Bedrock base_url, env_key = "AWS_BEARER_TOKEN_BEDROCK" and wire_api = "responses". Export AWS_REGION in your shell profile; Codex doesn’t read it from the AWS CLI profile. A “model metadata not found” warning at startup is harmless.

Step 2c: Claude Code (via LiteLLM)

  1. Install uv and save a litellm.yaml with one model: model_name: global.amazon.ergo-1.0, model: openai/global.amazon.ergo-1.0, api_base = the Bedrock OpenAI endpoint, api_key: os.environ/AWS_BEARER_TOKEN_BEDROCK, reasoning effort medium, plus drop_params: true and a local master_key placeholder.
  2. Start it: uv tool run --from 'litellm[proxy]' litellm --config litellm.yaml --host 127.0.0.1 --port 4000.
  3. Launch Claude Code from a script that sets ANTHROPIC_BASE_URL=http://127.0.0.1:4000, ANTHROPIC_AUTH_TOKEN to the same placeholder as master_key, ANTHROPIC_MODEL and the default Opus/Sonnet/Haiku and subagent model variables to global.amazon.ergo-1.0, CLAUDE_CODE_MAX_CONTEXT_TOKENS=1048568, and unset CLAUDE_CODE_USE_BEDROCK.
  4. If ~/.claude/settings.json sets CLAUDE_CODE_USE_BEDROCK or ANTHROPIC_MODEL in its env block, start with --setting-sources project,local.

The same proxy can enforce budgets per developer; see how to cap Claude Code spend per developer.

Troubleshooting

ErrorFix
400 “in-region isn’t supported”Use global.amazon.ergo-1.0 or us.amazon.ergo-1.0, not amazon.ergo-1.0
400 with reasoning_effort: noneErgo always reasons; use low → max
Empty answer, finish_reason: lengthRaise the output limit to ≥ 8,192 tokens
403 AccessDenied / UnrecognizedClientAdd the IAM policy; check the key hasn’t expired
429 ThrottlingLower the output limit or request a quota increase
Claude Code auth error from proxyANTHROPIC_AUTH_TOKEN must equal master_key

What it costs

$1.00 input, $3.00 output and $0.03 cache read per million tokens on Global cross-Region inference; 10% more on US cross-Region (AWS pricing page, December 3, 2026). Standard, Flex and Batch are the same price. Compare every model in our current API prices.

Last verified: December 3, 2026.

Sources