Skip to content

Amazon Ergo in Claude Code, Codex and OpenCode: Setup Guide

Matt Li By Matt Li, Co-Founder and Director 15 min read
How to use Amazon Ergo in Claude Code, Codex and OpenCode: setup guide by Second Talent.
TL;DR: Get one OpenRouter API key, save it as OPENROUTER_API_KEY, and use the model slug amazon/ergo-1.0 in OpenCode, Codex CLI or Claude Code. On December 2, 2026, all three fixed the same failing test on our Windows 11 PC: OpenCode in 39.6 seconds, Claude Code in 59.2 and Codex in 542.5. Claude Code needs a few extra variables, and Codex needs one Windows sandbox line.

On its first run with Ergo, Codex CLI could not start one shell command. All 18 tries came back "blocked by policy", so the model asked us to paste the files by hand. One line in config.toml fixed it.

I care less about Ergo's benchmark table than about how it copes with a real Windows shell, and that is where all three agents tripped first.

Key takeaways
  1. 1Claude Code's base URL is https://openrouter.ai/api, not /api/v1, because Claude Code adds /v1/messages itself.
  2. 2Ergo opened with Unix habits in PowerShell (ls -la, 2>/dev/null) in OpenCode and Codex, then corrected itself without help.
  3. 3OpenRouter served our Claude Code calls from Amazon Bedrock but our Codex calls from io.net, with one stall of about eight minutes.
  4. 4Every run in this guide together cost under $0.10 in OpenRouter credits.

Which route should you use for Ergo?

Use OpenRouter unless your company already runs on AWS. One OpenRouter key works in all three tools with the slug amazon/ergo-1.0, and none of them needs a proxy. The direct route uses a Bedrock key and the profile global.amazon.ergo-1.0.

Billing stays on your AWS account, but Claude Code then needs a local LiteLLM proxy.

Flowchart of the two routes to Amazon Ergo from OpenCode, Codex CLI or Claude Code: an OpenRouter key with the slug amazon/ergo-1.0, where OpenRouter picks a host such as Amazon Bedrock, io.net, inference.net, Morph or Featherless, or a Bedrock API key with global.amazon.ergo-1.0, where Claude Code needs a LiteLLM proxy.

Amazon released Ergo on December 1, 2026. It is an open-weights model with a one-million-token context window, and it reads text only.

AWS charges $1.00 per million input tokens and $3.00 per million output tokens on its Global profile, per the Ergo pricing page. For how it codes against Anthropic's model, see our Amazon Ergo review and Ergo vs Claude test.

OpenRouter (what we ran)
  • Key in OPENROUTER_API_KEY
  • Model amazon/ergo-1.0 in all three tools
  • No proxy, Claude Code included
  • OpenRouter picks the host unless you restrict it
Amazon Bedrock direct
  • Key in AWS_BEARER_TOKEN_BEDROCK
  • Model global.amazon.ergo-1.0
  • Claude Code needs LiteLLM on port 4000
  • Billing and IAM stay in your AWS account

Step 1: get a key and save it on Windows

Create an API key in your OpenRouter account and add a few dollars of credit. Then save it as a user-level variable. That way each tool can read it, and the key stays out of your config files:

# PowerShell, either line works
setx OPENROUTER_API_KEY "sk-or-v1-..."
[Environment]::SetEnvironmentVariable("OPENROUTER_API_KEY", "sk-or-v1-...", "User")

Close the terminal and open a new one. Neither command changes the window you ran it in. Check it with if ($env:OPENROUTER_API_KEY) { "set" }, which avoids printing the key to your screen.

On macOS or Linux, add export OPENROUTER_API_KEY="sk-or-v1-..." to your shell profile.

For the Bedrock route, follow AWS's Ergo coding-tools page. Open the Bedrock console, choose API keys, then Create long-term key. Save the value as AWS_BEARER_TOKEN_BEDROCK.

The user behind the key also needs the two invoke permissions that page lists.

How to use Ergo in OpenCode

39.6 s to a passing testv2.4.3 from npm0 config files needed

OpenCode was the fastest of the three and needed no setup beyond the key. It reads OPENROUTER_API_KEY by itself, so you only add the model flag. Install it with the package name from the OpenCode docs:

npm install -g @opencode/cli
opencode --version
opencode run --auto -m openrouter/amazon/ergo-1.0 "test.js fails. Find the bug in orders.js and fix it, then run node test.js to confirm it passes. Do not edit test.js."

Older guides, OpenRouter's among them, still name the package opencode-ai.

On npm that is the old 1.x line (1.19.6 when we checked). @opencode/cli gave us 2.4.3. npm warned that it had skipped the package's setup script: npm warn install-scripts @opencode/cli@2.4.3 (postinstall: node ./postinstall.mjs).

Even so, opencode --version answered "opencode v2.4.3", and the run worked.

For daily use, start opencode in your project and type /connect. Pick OpenRouter, paste the key, then pick Ergo under /models. To make Ergo the default, set "model" to "openrouter/amazon/ergo-1.0" in ~/.config/opencode/opencode.json.

What happened in our OpenCode run

Our test project holds an orders.js that sorts date strings with a.date - b.date. That returns NaN, so a "latest three orders" function keeps the oldest three. Ergo's first command was ls -la, which PowerShell rejects.

It moved to OpenCode's own Glob tool, read both files and ran the test to see it fail:

PowerShell output of opencode run with openrouter/amazon/ergo-1.0: Ergo tries ls -la and gets a PowerShell parameter error, switches to Glob, reads orders.js and test.js, sees the assertion fail with [1,2,3], edits orders.js twice and ends with PASS: latestOrders keeps the 3 newest orders.

The first edit had a bug of its own. Ergo sorted a copy into sorted but left the loop reading orders. It caught that and fixed the loop in a second edit.

Its closing note was right on all three points: the NaN sort, the newest-first input, and the copy that leaves the caller's array alone.

How to use Ergo in Codex CLI

Codex needs a custom provider in ~/.codex/config.toml. This is the file we ran. It follows OpenRouter's Codex CLI guide, plus the Windows block we added after run 1:

model = "amazon/ergo-1.0"
model_provider = "openrouter"
model_reasoning_effort = "medium"

[model_providers.openrouter]
name = "openrouter"
base_url = "https://openrouter.ai/api/v1"

[model_providers.openrouter.auth]
command = "powershell"
args = ["-NoProfile", "-Command", "Write-Output $env:OPENROUTER_API_KEY"]

[windows]
sandbox = "unelevated"

The auth block asks PowerShell for the key at startup, so the file does not hold it. On macOS and Linux, OpenRouter's guide uses sh instead.

The shorter env_key = "OPENROUTER_API_KEY" also works, but then Codex skips OpenRouter's model list. If you are installing Codex for the first time, start with our Codex install guide.

Run 1: every command blocked by policy

Without the [windows] block, Codex 0.172.0 blocked all 18 shell commands Ergo tried, from cmd.exe to powershell.exe -Command whoami. The header showed sandbox: read-only, though we had passed -s workspace-write.

After 162 seconds and 19,827 tokens, Ergo asked for the files:

Codex CLI 0.172.0 run 1 with amazon/ergo-1.0 on OpenRouter: the header shows sandbox read-only, every shell command is rejected as blocked by policy, and after 19,827 tokens Ergo asks for a way to get command execution working.

The cause is Codex's Windows sandbox, not Ergo. OpenAI's Windows sandbox docs say Codex picks the elevated mode when no mode is set. That mode needs a setup step an admin approves. Our fresh Codex home had not run it yet.

Elevated or unelevated? OpenAI calls unelevated a fallback: it runs commands under a restricted token from your own account and gives weaker network isolation than elevated. If you can approve the admin setup, elevated is the stricter choice.

Run 2: a pass, and a slow provider

With sandbox = "unelevated", the same command passed. Ergo again tried Unix syntax first: ls -la, then cat test.js 2>/dev/null. PowerShell turned that into a failed write to D:\dev\null.

Ergo moved to Get-ChildItem and Get-Content and fixed the sort and the loop in one edit. The test passed:

Codex CLI run 2 with the unelevated Windows sandbox: a cat with 2>/dev/null fails on D:\dev\null, Get-ChildItem succeeds in 551 ms, the patch sorts a copy of the orders by parsed date, and node test.js prints PASS after 17,994 tokens.

The run took 542.5 seconds, yet each command finished in under a second. OpenRouter's activity log shows io.net served these Codex calls, with one gap of about eight minutes between two of them. inference.net handled an earlier call.

Our Claude Code calls, minutes later, ran on Amazon Bedrock. In my understanding, the Codex time measures that host, not Ergo.

How to use Ergo in Claude Code

Claude Code speaks Anthropic's API format, and OpenRouter accepts it at https://openrouter.ai/api. Point Claude Code there with the variables from OpenRouter's Claude Code guide. Leave off the /v1.

Claude Code adds /v1/messages itself, so /api/v1 ends in a 404.

VariableValueWhy
ANTHROPIC_BASE_URLhttps://openrouter.ai/apiSends requests to OpenRouter
ANTHROPIC_AUTH_TOKENYour OpenRouter keySigns each request
ANTHROPIC_API_KEYEmptyKeeps a second credential from competing with the token
ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, CLAUDE_CODE_SUBAGENT_MODELamazon/ergo-1.0Puts Ergo in every model slot, subagents included
CLAUDE_CODE_MAX_CONTEXT_TOKENS1048568Claude Code assumes a 200K window unless a model name ends in [1m]

I would not put these in your user-level ~/.claude/settings.json. Values there are literal, so the key would sit in the file, and all your Claude Code sessions would switch to Ergo. A launcher sets them for one window only.

This is the PowerShell version we use, saved as claude-ergo.ps1:

# claude-ergo.ps1: run Claude Code on Ergo through OpenRouter, this window only
$env:ANTHROPIC_BASE_URL = "https://openrouter.ai/api"
$env:ANTHROPIC_AUTH_TOKEN = $env:OPENROUTER_API_KEY
$env:ANTHROPIC_API_KEY = ""
$env:ANTHROPIC_MODEL = "amazon/ergo-1.0"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "amazon/ergo-1.0"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "amazon/ergo-1.0"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "amazon/ergo-1.0"
$env:CLAUDE_CODE_SUBAGENT_MODEL = "amazon/ergo-1.0"
$env:CLAUDE_CODE_MAX_CONTEXT_TOKENS = "1048568"
claude --setting-sources "project,local" @args

In Windows PowerShell, an empty string clears the variable, which is what our run used. The --setting-sources "project,local" flag skips your user settings, so an old env block there cannot override the launcher.

Run .\claude-ergo.ps1 in a project, then type /status. OpenRouter's guide says it should show the auth token as the credential.

Two notices, then a pass

We ran the same task with claude -p and five allowed tools: Read, Edit, Glob, Grep and node test.js. Claude Code printed two notices first. One said it had turned off claude.ai connectors because another auth source was set.

The other was an unrecognized_model line for amazon/ergo-1.0. Neither stopped the run:

Claude Code run on Ergo through OpenRouter: a notice that claude.ai connectors are disabled, an unrecognized_model line for amazon/ergo-1.0, then Ergo's answer explaining the NaN sort bug and the one-line fix with new Date.

Ergo made the smallest change of the three runs: one line that parses both dates. It flagged the in-place sort as a side note and left it alone. OpenRouter logged five calls, all served by Amazon Bedrock:

16K to 17.5K
Input tokens per call. Most of it is Claude Code's own prompt and tools.
5.4 to 11.9 s
Time per call on Amazon Bedrock.
About $0.03
For the whole run. The first call cost $0.0206 before caching.
Source: OpenRouter activity log for our Claude Code run, December 2, 2026.

Output ran from 82 to 622 tokens per call, so most of the bill was Claude Code's fixed prompt. Both vendors attach caveats to this setup:

"Anthropic doesn't endorse ... and doesn't support routing Claude Code to non-Claude models through any gateway."

Anthropic, Claude Code LLM gateway docs

OpenRouter adds its own warning. Its guide says Claude Code "is only guaranteed to work with the Anthropic first-party provider." Ergo worked for us, but a Claude Code update can break it without notice.

The same pattern runs GLM and Kimi, as our GLM and Kimi in Claude Code guide shows. Anthropic's variable reference lists each one above.

How the three runs compared

All three agents ended with a passing test and a correct account of the NaN bug. Two runs sorted a copy and one sorted in place, and all three parsed the dates. The time gap came from the hosts and the Codex sandbox:

Bar chart of wall-clock time to fix the same failing test with Ergo on December 2, 2026: OpenCode 39.6 seconds, Claude Code 59.2 seconds, Codex CLI run 1 162 seconds and failed, Codex CLI run 2 542.5 seconds served by io.net with one stall of about 8 minutes.
ToolResultHost on OpenRouterWhat went wrong first
OpenCode 2.4.3Pass, 39.6 sNot recordedls -la in PowerShell; a first edit that looped over the wrong array
Claude CodePass, 59.2 sAmazon Bedrock, 5 callsTwo startup notices, no errors
Codex CLI 0.172.0, run 1Fail, 162 sNot recordedEvery command blocked by policy
Codex CLI 0.172.0, run 2Pass, 542.5 sio.netls -la and 2>/dev/null; one stall of about 8 minutes

OpenRouter's Ergo model page listed five hosts when we checked: Amazon Bedrock, io.net, inference.net, Morph and Featherless. They charge $0.90 to $1.10 per million input tokens.

To keep a slow host out, OpenRouter's provider selection docs offer three options:

  • Account-wide: allow or ignore providers for all requests in your OpenRouter privacy settings. This one reaches all three tools, since none lets you edit the request body.
  • Per request: a provider object with order, only or ignore, and allow_fallbacks: false to stop it falling back.
  • In the slug: append :nitro to sort hosts by speed, for example amazon/ergo-1.0:nitro. We did not test this suffix in the three tools.

Bedrock direct: AWS's documented setup

These are the steps from AWS's Ergo coding-tools page. We read them on December 2, 2026 but did not run them; our tests used OpenRouter. All three use the us-west-2 endpoint and the AWS_BEARER_TOKEN_BEDROCK key from step 1.

OpenCode on Bedrock

OpenCode talks to Bedrock's OpenAI-style endpoint with no proxy. This is AWS's version of the same config file:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "bedrock-runtime": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Amazon Bedrock",
      "options": {
        "baseURL": "https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1",
        "apiKey": "{env:AWS_BEARER_TOKEN_BEDROCK}"
      },
      "models": {
        "global.amazon.ergo-1.0": {
          "name": "Ergo 1.0",
          "limit": { "context": 1048568, "output": 131072 },
          "options": { "reasoningEffort": "medium" }
        }
      }
    }
  },
  "model": "bedrock-runtime/global.amazon.ergo-1.0"
}

AWS notes that each request holds its full output limit against your quota. Lower limit.output if you hit throttling.

Codex CLI on Bedrock

Codex uses Bedrock's Responses API. Web search has to be off, since Bedrock does not run Codex's built-in web tools:

model = "global.amazon.ergo-1.0"
model_provider = "bedrock-runtime"
model_reasoning_effort = "medium"
web_search = "disabled"
model_context_window = 1048568

[model_providers.bedrock-runtime]
name = "Amazon Bedrock"
base_url = "https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1"
env_key = "AWS_BEARER_TOKEN_BEDROCK"
wire_api = "responses"

AWS also says to set AWS_REGION=us-west-2. Codex does not read the Region from your AWS CLI profile. On Windows that is setx AWS_REGION us-west-2, our version of AWS's shell-profile step.

AWS says a startup line about model metadata "not found" is harmless. On Windows, keep the [windows] block from the OpenRouter config too.

Claude Code on Bedrock, through LiteLLM

Claude Code cannot call Bedrock's OpenAI-style endpoint itself. AWS's fix is a local LiteLLM proxy that translates. Save AWS's config as litellm.yaml in a new ~/ergo-claude-code folder:

model_list:
  - model_name: global.amazon.ergo-1.0
    litellm_params:
      model: openai/global.amazon.ergo-1.0
      api_base: https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1
      api_key: os.environ/AWS_BEARER_TOKEN_BEDROCK
      extra_body:
        reasoning:
          effort: medium
litellm_settings:
  drop_params: true
general_settings:
  master_key: sk-ergo-local

sk-ergo-local is a local placeholder, not a credential. It only has to match the token Claude Code sends.

Start the proxy with uv tool run --from 'litellm[proxy]' litellm --config ~/ergo-claude-code/litellm.yaml --host 127.0.0.1 --port 4000, and restart it after any key change.

AWS only gives a bash launcher. This PowerShell copy is our translation, and we have not run it:

# claude-ergo-bedrock.ps1: our PowerShell translation of AWS's bash launcher (untested)
$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:4000"
$env:ANTHROPIC_AUTH_TOKEN = "sk-ergo-local"   # must match master_key in litellm.yaml
$env:ANTHROPIC_MODEL = "global.amazon.ergo-1.0"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "global.amazon.ergo-1.0"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "global.amazon.ergo-1.0"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "global.amazon.ergo-1.0"
$env:CLAUDE_CODE_SUBAGENT_MODEL = "global.amazon.ergo-1.0"
$env:CLAUDE_CODE_MAX_CONTEXT_TOKENS = "1048568"
Remove-Item Env:CLAUDE_CODE_USE_BEDROCK -ErrorAction SilentlyContinue
claude @args

Troubleshooting Ergo in coding agents

The first four rows come from our runs and OpenRouter's guides. The rest come from AWS's table for the Bedrock route.

SymptomCauseFix
Codex: "rejected: blocked by policy" on every commandWindows sandbox mode not set upAdd [windows] with sandbox = "unelevated", or run the elevated setup as an administrator
"A parameter cannot be found that matches parameter name 'la'" or a path ending in \dev\nullErgo used Unix commands in PowerShellNothing; it recovered in both runs. A note in your project's agent instructions that the shell is PowerShell may save a turn
Claude Code returns 404Base URL ends in /api/v1Use https://openrouter.ai/api
Long pauses between tool callsA slow host on OpenRouterRestrict providers in OpenRouter's settings, or try the :nitro slug
403 UnrecognizedClientExceptionBedrock key unset or expiredSet AWS_BEARER_TOKEN_BEDROCK again
Empty answer, finish_reason "length"Output limit too low; Ergo spends part of it reasoningRaise the output limit to at least 8,192 tokens
400 error with reasoning effort "none"Ergo always reasonsUse low, medium, high, xhigh or max
Codex error about web_searchBedrock does not run server-side toolsSet web_search = "disabled"
Authentication error from the LiteLLM proxyToken does not match master_keyMake ANTHROPIC_AUTH_TOKEN equal the master_key

Developers who use more than one model

Switching the model under an agent took us minutes. Knowing when Ergo's lower price is worth a slower host takes engineers who have shipped with several models.

Second Talent matches US teams with pre-vetted senior developers within 24 hours. Hire developers who already run Claude Code, Codex and open models. To compare the agents first, see our AI coding agents roundup.

FAQs

Do I need a Claude subscription to run Ergo in Claude Code?

No. With ANTHROPIC_AUTH_TOKEN set, Claude Code uses that token instead of your claude.ai login. OpenRouter bills the usage to your credits. You still need Claude Code installed.

Can Ergo read images or screenshots in these tools?

No. Ergo takes text in and gives text out, per Amazon's Hugging Face model card. Pasting a screenshot into the agent will not help it.

Does Ergo work in Kiro?

AWS lists Kiro as a supported tool on its Ergo page. The page has no setup steps for it, and we did not try it.

Can I use the US inference profile instead of Global?

Yes. Swap global.amazon.ergo-1.0 for us.amazon.ergo-1.0 to keep requests in US Regions. AWS charges $1.10 per million input tokens and $3.30 per million output tokens, against $1.00 and $3.00 on Global.

Get developers who ship with AI agents. Starts at $25/Hour.

Start Hiring $0 cost until you hire
Matt Li

Written by

Matt Li is a tech-driven entrepreneur with deep expertise in global talent strategy, digital experience optimization, e-commerce, and Web3 innovation. He is the Co-Founder of Second Talent, a US-based company that connects businesses with top-tier tech professionals worldwide. Since launching the company in 2024, Matt has led its growth by leveraging technology to streamline remote hiring and scale distributed teams. With a background spanning product, operations, and innovation, Matt brings a cross-disciplinary perspective to the evolving digital economy. His work sits at the intersection of global talent, emerging technology, and scalable digital transformation.

More posts by Matt Li →