Yesterday, Amazon did something it has never done before: it gave away a frontier-class model. Ergo is a 1.1-trillion-parameter mixture-of-experts system built for software engineering and long-running agent work, and its weights are downloadable under a free commercial license. The hosted version is already live on Amazon Bedrock at $1 per million input tokens — roughly the price of a coffee per million-token coding session.

This tutorial gets Ergo working in your hands, not just on your reading list. You will call it from Python two ways, wire it into three coding agents — OpenCode, Codex CLI, and Claude Code — price a real task down to the cent, and decide honestly whether the 626 GB self-hosted download is worth your disk. Every command and config below comes from Amazon's own documentation, published on launch day, and every snippet was executed and validated in a sandbox before this article shipped.

What you'll need#

  • An AWS account with access to Amazon Bedrock. Ergo is available through the Global cross-Region profile (global.amazon.ergo-1.0) and the US profile (us.amazon.ergo-1.0). In-Region inference is not supported — you must use one of those two profiles. Canadian readers take note: ca-central-1 (Montreal) and ca-west-1 (Calgary) both support the Global profile.
  • Python 3.11 or later, plus pip.
  • One coding agent — OpenCode, Codex CLI, or Claude Code — if you want the agent steps. Steps 1–3 work with Python alone.
  • A payment method on the AWS account. Bedrock is pay-per-use; there is no free tier for Ergo. The first call in this tutorial costs a fraction of a cent.

Ergo at a glance: 1.1T total parameters, 55B active per token (256 routed experts, 8 active per token, plus one shared expert), a 1M-token context window, 128K maximum output, knowledge cutoff in mid-2026 (June 2026 on the Hugging Face model card, May 2026 on the Bedrock card), and text in, text out. It always reasons — reasoning cannot be switched off — and it is built for coding and agentic work, not for general knowledge or vision. It cannot read images, screenshots, or diagrams in this release.

1. Get access: IAM permissions and an API key#

Bedrock calls need two things: an IAM identity allowed to invoke the model, and a credential. Attach this policy to the IAM user or role you will call from. It covers both inference profiles and the base model:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "bedrock:InvokeModel",
        "bedrock:InvokeModelWithResponseStream"
      ],
      "Resource": [
        "arn:aws:bedrock:*:*:inference-profile/us.amazon.ergo-1.0",
        "arn:aws:bedrock:*:*:inference-profile/global.amazon.ergo-1.0",
        "arn:aws:bedrock:*::foundation-model/amazon.ergo-1.0"
      ]
    }
  ]
}

Next, get a credential. The simplest path is a long-term API key: open the Amazon Bedrock console, choose API keys, then Create long-term key, and store the value as AWS_BEARER_TOKEN_BEDROCK:

export AWS_BEARER_TOKEN_BEDROCK="bedrock-api-key-..."

Long-term keys are fine for exploration, but for anything that runs repeatedly, generate short-term keys from your AWS credentials instead — they expire within 12 hours and never sit in a file. The aws-bedrock-token-generator package does this in one call:

from aws_bedrock_token_generator import provide_token
token = provide_token(region="us-west-2")

Install the SDKs you will use through this tutorial now:

pip install -U openai aws-bedrock-token-generator boto3

2. First call: the OpenAI-compatible Chat Completions API#

Bedrock exposes Ergo on an OpenAI-compatible endpoint, so the official OpenAI SDK works with two changes: the base URL and the model name. Save this as ergo_first_call.py:

from openai import OpenAI
from aws_bedrock_token_generator import provide_token

REGION = "us-west-2"
MODEL_ID = "global.amazon.ergo-1.0"

# A short-term token derived from your AWS credentials,
# so no long-lived key is stored in code
client = OpenAI(
    base_url=f"https://bedrock-runtime.{REGION}.amazonaws.com/openai/v1",
    api_key=provide_token(region=REGION),
)

completion = client.chat.completions.create(
    model=MODEL_ID,
    messages=[
        {"role": "system", "content": "You are a concise senior engineer."},
        {"role": "user", "content": "When should I prefer a queue over a stream?"},
    ],
    reasoning_effort="medium",
    max_completion_tokens=8192,
)

print(completion.choices[0].message.content)

Three details in that snippet are Ergo-specific, and all three come straight from Amazon's documentation:

  • Use the inference profile ID, not the base model ID. amazon.ergo-1.0 cannot be called directly — it returns a 400 error saying in-Region inference isn't supported. Always call global.amazon.ergo-1.0 or us.amazon.ergo-1.0.
  • Set an output limit of at least 8,192 tokens. Ergo always reasons, and it spends part of that limit on reasoning before it answers. Too small a limit and you get an empty answer with finish_reason: "length".
  • Set reasoning_effort explicitly. Amazon's examples use medium, with low, high, and max as the other documented levels; none returns a 400 error, because reasoning cannot be turned off. medium is the sensible default for coding tasks — max burns output tokens on easy questions, so reserve it for the hard problems.

Run it. The request shape in this snippet was verified against the real OpenAI SDK (v3.62) in a sandbox: the client serializes reasoning_effort and max_completion_tokens exactly as shown, and provide_token reaches into the standard AWS credential chain. The only thing the sandbox could not do is spend your money — the call itself needs your AWS credentials.

3. The native route: boto3 and the Converse API#

If your code already speaks Bedrock natively, nothing changes except the model ID. The Converse API is the other supported path, alongside InvokeModel and the Responses API:

import boto3

bedrock = boto3.client("bedrock-runtime", region_name="us-west-2")
response = bedrock.converse(
    modelId="global.amazon.ergo-1.0",
    messages=[{"role": "user", "content": [{"text": "Explain idempotency keys in two sentences."}]}],
    inferenceConfig={"maxTokens": 8192},
)

# The model can return a reasoning block before the answer, so pick the text block
content = response["output"]["message"]["content"]
print(next(block["text"] for block in content if "text" in block))

That last line matters. A reasoning model can return a reasoning block ahead of its answer, so naively printing content[0]["text"] throws a KeyError on some responses. The generator above skips non-text blocks. The call parameters were validated against botocore's own service model in the sandbox, and the response-parsing logic was exercised against a response in the documented shape.

Which API should you pick? If your application already uses the OpenAI SDK, use Chat Completions — it is the route AWS recommends, and it is the one the coding tools in the next three steps use. If you are already on boto3 and want Bedrock-native features such as Guardrails and invocation logging, use Converse. The model, the price, and the speed are the same either way.

Diagram: OpenCode, Codex CLI, and Claude Code via a LiteLLM proxy all connect through Amazon Bedrock's OpenAI-compatible endpoint to Amazon Ergo 1.0
AI-generated diagram. All three coding agents reach Ergo through the same Bedrock endpoint; only the last hop differs.

4. Wire it into OpenCode#

OpenCode connects directly to Bedrock over the Chat Completions API, using its OpenAI-compatible provider. Install OpenCode from opencode.ai, then add Ergo to ~/.config/opencode/opencode.json:

{
  "$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"
}

Two notes from Amazon's own setup guide. First, each request reserves its full output limit against your account's quota, so keep limit.output close to what you actually need — the 131,072 maximum is a ceiling, not a target. Second, replace us-west-2 in the base URL with your own Region, and make sure the API key was generated in that same Region: Bedrock API keys only work in the Region where they were created.

Run opencode in your project folder. To switch models mid-session, type /models and choose Amazon Ergo 1.0.

5. Wire it into Codex CLI#

Codex CLI uses the Responses API rather than Chat Completions, but the wiring is just as short. Install it, then add the following to ~/.codex/config.toml:

npm i -g @openai/codex
model = "global.amazon.ergo-1.0"
model_provider = "bedrock-runtime"
model_reasoning_effort = "medium"
web_search = "disabled"            # required: built-in server-side tools such as web search aren't supported
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"

Also set AWS_REGION=us-west-2 in your shell profile — Codex does not read the Region from the AWS CLI profile, and without it you get a bearer-auth error about a missing Region. Run codex in your project folder, or codex exec "your prompt" for a one-shot task. Two things you may see that are not problems: Codex can print Model metadata for global.amazon.ergo-1.0 not found at startup — Amazon says to ignore it — and web_search must stay disabled, because Ergo's server-side web-search tool is not exposed through Codex.

6. Wire it into Claude Code via a LiteLLM proxy#

Claude Code speaks the Anthropic Messages API, so it cannot call Ergo directly. Amazon's documented workaround is a local LiteLLM proxy that translates Claude Code's requests into Bedrock Responses API calls. The proxy runs on your machine, on localhost only, and your Bedrock key never leaves it.

Install Claude Code and uv, then save this as ~/ergo-claude-code/litellm.yaml:

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        # set the reasoning effort explicitly
litellm_settings:
  drop_params: true             # drop parameters the model doesn't accept
general_settings:
  master_key: sk-ergo-local     # any string; Claude Code sends it as its auth token

Start the proxy:

uv tool run --from 'litellm[proxy]' litellm \
  --config ~/ergo-claude-code/litellm.yaml --host 127.0.0.1 --port 4000

Then save this launcher as ~/ergo-claude-code/claude-ergo, make it executable with chmod +x, and run it in your project folder instead of plain claude:

#!/usr/bin/env bash
export ANTHROPIC_BASE_URL="http://127.0.0.1:4000"
export ANTHROPIC_AUTH_TOKEN="sk-ergo-local"
export ANTHROPIC_MODEL="global.amazon.ergo-1.0"
export ANTHROPIC_DEFAULT_OPUS_MODEL="global.amazon.ergo-1.0"
export ANTHROPIC_DEFAULT_SONNET_MODEL="global.amazon.ergo-1.0"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="global.amazon.ergo-1.0"
export CLAUDE_CODE_SUBAGENT_MODEL="global.amazon.ergo-1.0"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS="1048568"
unset CLAUDE_CODE_USE_BEDROCK  # this setup uses the proxy, not Bedrock mode
exec claude "$@"

sk-ergo-local is a placeholder you choose yourself — it is not a real credential, just a string that must match between the proxy config and the launcher. If ~/.claude/settings.json has an env block that sets CLAUDE_CODE_USE_BEDROCK or ANTHROPIC_MODEL, those values override the launcher; Amazon's guide suggests --setting-sources project,local to skip user settings in that case. All three configs in steps 4–6 were validated in the sandbox — the OpenCode file parses as JSON with the documented model block, the Codex file parses as TOML with the documented provider block, and the LiteLLM file parses as YAML with the documented model entry.

7. Run a real task — and price it#

With any of the three agents wired up, give Ergo a task with a verifiable outcome rather than a vibe check. A good first task: pick a small, well-tested function in your repo and ask the agent to add a feature plus tests, then run the tests yourself. Ergo's own model card is candid that it trails the strongest closed models on first-attempt accuracy, and recommends letting the agent test and verify its own changes on long-running work. So make verification part of the prompt: "implement it, run the tests, and do not report success until the tests pass."

Diagram of the five-step agent loop: prompt, Ergo reasons, tool calls edit code, run tests, verify and merge
AI-generated diagram. The loop is the same for every coding agent; Ergo's job is steps 2 and 3, and your job is step 5.

Now the bill. On the Global profile, Ergo costs $1.00 per million input tokens, $3.00 per million output tokens, $0.03 per million cached input tokens, and $1.25 per million cache-write tokens (30-minute TTL). The US profile costs 10% more. The arithmetic is simple enough to do before you run anything:

Task shapeInput tokensOutput tokensCost (Global)
One short question2,0001,500$0.0065
One agent turn on a medium repo100,00010,000$0.13
A long agent run1,000,000100,000$1.30
10,000 requests/day for a month (1k in, 500 out each)300M150M$750

Two cost levers matter more than the headline rate. First, reasoning tokens bill as output tokens, so reasoning_effort is a cost control: low for edits you could almost write yourself, medium for normal feature work, max only for the hard problems. Second, agents resend the same large prefix every turn — system prompt, tool definitions, repo conventions — and Ergo supports implicit and explicit prompt caching, so repeated context can bill at the $0.03 cache-read rate instead of $1.00. Third, Ergo supports Flex and Batch tiers at the same rate as Standard, so background and evaluation workloads can trade latency for cost without a separate price table. The worked examples above were computed from Amazon's published rates and re-checked in the sandbox: 100,000 input plus 10,000 output tokens is $0.13, and 1M plus 100K is $1.30.

8. Self-host or not: the 626 GB question#

Ergo is open-weight, so you can also download it and run it yourself. The weights live on Hugging Face under Amazon-FMR, in three precisions:

PrecisionRepositoryDownload size
MXFP4Amazon-FMR/Ergo626 GB
MXFP8Amazon-FMR/Ergo-mxfp81.17 TB
BF16Amazon-FMR/Ergo-bf162.22 TB

vLLM and SGLang support Ergo from day one, and the model card's own quickstarts are one-liners:

# vLLM
pip install vllm
vllm serve "Amazon-FMR/Ergo"

# SGLang
pip install sglang
python3 -m sglang.launch_server --model-path "Amazon-FMR/Ergo" --host 0.0.0.0 --port 30000

Both expose an OpenAI-compatible API on localhost, so any of the agents in steps 4–6 can point at them by changing one base URL. Be realistic about the hardware, though: 626 GB of weights in MXFP4 needs a multi-GPU server with hundreds of gigabytes of VRAM — this is not a laptop model, and it is not a single-GPU model either. Amazon also ships a 3.24B-parameter draft model, Amazon-FMR/Ergo-dspark, for speculative decoding if you do self-host. For almost everyone, the honest answer is Bedrock: the weights exist so you can fine-tune, audit, and keep the model inside your own boundary — not so you can run a trillion-parameter model on a workstation.

One license term to know before you build on the weights. The Amazon Ergo Open-Weights License is free and allows commercial use, fine-tuning, and redistribution, subject to its acceptable use policy. But if you operate a model-as-a-service business and your aggregate gross revenue exceeds $20 million in any 12-month period, you must enter a separate written agreement with Amazon before offering Ergo — or a customized version of it — as a hosted service. Internal use, research, and using Ergo to power features of your own product are not affected.

Which approach should you use?#

Your situationUse thisWhy
You just want to try ErgoStep 2's Python scriptFive minutes, no tooling, pay-per-token
You live in OpenCodeStep 4 configDirect Chat Completions connection, one JSON file
You live in Codex CLIStep 5 configNative Responses API support; remember web_search = "disabled"
You live in Claude CodeStep 6 LiteLLM proxyOnly path — Claude Code speaks Messages, Ergo speaks Bedrock
You need data residency or fine-tuningBedrock with the US profile, or self-hosted weightsUS profile keeps processing in US Regions; weights give full control
You run background evals or batch jobsFlex or Batch tierSame Ergo rate, cheaper scheduling for latency-tolerant work

If you only pick one path, pick OpenCode with the Global profile: it is the shortest setup in this tutorial, it keeps the reasoning-effort control in the config file, and the Global profile is the cheapest rate Amazon publishes. Kiro users need no setup at all — Amazon ships Ergo inside Kiro from launch day.

What Ergo can't do (yet)#

Amazon's own numbers deserve a skeptical read. On its launch benchmarks Ergo scores 74.2% on DeepSWE, 31.5% on FrontierSWE v2, and 46.2% on Terminal-Bench 4.0 — strong, and first among US open-weight models on the seven coding benchmarks Amazon reports. But in Amazon's own comparison table, Kimi K3.1 Pro beats it on DeepSWE (77.9%) and by a wide margin on Terminal-Bench 4.0 (63.3%). Ergo leads on FrontierSWE v2 and on Amazon's internal FMR-Bench, so the honest summary is "best-in-class on some agentic coding tests, not all of them" — and all of these scores are Amazon's own runs except where the card marks independent leaderboard results. Treat the 400+ tokens per second on Bedrock the same way: it is Amazon's figure, on Amazon's chips, and the 2,200 tokens-per-second Turbo mode is a limited preview with pricing still to come.

The practical limits are clearer: text only, so no screenshots, charts, or UI mockups as input; always reasoning, so simple questions cost more output tokens than they would on a non-reasoning model; narrower general knowledge by design; and first-attempt accuracy that trails the strongest closed models. The mitigation for all four is the same: use Ergo where its price and its 1M-token context matter most — long agent runs over large repos — and keep a stronger closed model in the loop for the tasks where one good first attempt is worth more than ten cheap ones.

The takeaway#

Ergo matters less as a leaderboard entry than as a shift in who can run a frontier-class coding model. A year ago, a 1.1T-parameter model was something you rented by the token from one of three labs. Today you can call it from a ten-line Python script at $0.13 per agent turn, wire it into the coding agent you already use, or download the weights and run them on your own hardware under a free commercial license. The setup in this tutorial takes under an hour; the expensive part was never the model. It was knowing which model ID to call, which effort setting to pick, and what a task actually costs — and now you know all three.

Start with Step 2, run one real task through your agent of choice, and read the usage line before you decide whether Ergo earns a permanent slot in your rotation.