How to Use Amazon Ergo in Claude Code, Codex and OpenCode
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
| OpenCode | Codex CLI | Claude Code | Kiro | |
|---|---|---|---|---|
| Connection | Direct, Chat Completions | Direct, Responses API | LiteLLM proxy → Responses API | Native |
| Extra software | None | None | uv + LiteLLM | None |
| Config file | ~/.config/opencode/opencode.json | ~/.codex/config.toml | litellm.yaml + launcher script | — |
| Gotcha | Keep limit.output near what you need (it reserves quota) | Must set web_search = "disabled" and AWS_REGION | Settings env block can override the launcher | — |
| Pick when | You want the simplest open-source setup | You already use Codex | Your team’s workflow lives in Claude Code | You’re on AWS’s own IDE |
Step 1: Prerequisites (all tools)
- 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 fromaws-bedrock-token-generatoralso work but expire. - Attach an IAM policy allowing
bedrock:InvokeModelandbedrock:InvokeModelWithResponseStreamoninference-profile/us.amazon.ergo-1.0,inference-profile/global.amazon.ergo-1.0andfoundation-model/amazon.ergo-1.0. - Use the endpoint
https://bedrock-runtime.<region>.amazonaws.com/openai/v1(AWS’s examples useus-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)
- Install
uvand save alitellm.yamlwith 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 effortmedium, plusdrop_params: trueand a localmaster_keyplaceholder. - Start it:
uv tool run --from 'litellm[proxy]' litellm --config litellm.yaml --host 127.0.0.1 --port 4000. - Launch Claude Code from a script that sets
ANTHROPIC_BASE_URL=http://127.0.0.1:4000,ANTHROPIC_AUTH_TOKENto the same placeholder asmaster_key,ANTHROPIC_MODELand the default Opus/Sonnet/Haiku and subagent model variables toglobal.amazon.ergo-1.0,CLAUDE_CODE_MAX_CONTEXT_TOKENS=1048568, andunset CLAUDE_CODE_USE_BEDROCK. - If
~/.claude/settings.jsonsetsCLAUDE_CODE_USE_BEDROCKorANTHROPIC_MODELin itsenvblock, start with--setting-sources project,local.
The same proxy can enforce budgets per developer; see how to cap Claude Code spend per developer.
Troubleshooting
| Error | Fix |
|---|---|
| 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: none | Ergo always reasons; use low → max |
Empty answer, finish_reason: length | Raise the output limit to ≥ 8,192 tokens |
| 403 AccessDenied / UnrecognizedClient | Add the IAM policy; check the key hasn’t expired |
| 429 Throttling | Lower the output limit or request a quota increase |
| Claude Code auth error from proxy | ANTHROPIC_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.