View a markdown version of this page

Use Amazon Ergo-1.0 with coding tools - Amazon Bedrock

Use Amazon Ergo-1.0 with coding tools

You can use Amazon Ergo-1.0 with popular coding tools including Claude Code, Codex CLI, OpenCode, and Kiro. This page explains how to configure each tool to call Amazon Ergo-1.0 through Amazon Bedrock. For more information, see Amazon Ergo-1.0.

Prerequisites

Complete the following steps before you configure a coding tool.

Create an AWS account

If you already have an AWS account, skip this step. To create a new account, go to Sign up for AWS.

Required IAM permissions

Attach a policy that allows invoking Amazon Ergo-1.0 to the IAM identity that makes calls. The following policy allows invoking Amazon Ergo-1.0 through the US and Global cross-Region inference profiles.

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

Generate an API key

To generate a long-term API key, go to the Amazon Bedrock console and choose API keys, then choose Create long-term key. Store the key value as the environment variable AWS_BEARER_TOKEN_BEDROCK.

As an alternative, you can generate a short-term key programmatically using aws-bedrock-token-generator:

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

Short-term keys expire; you must regenerate them when expired.

Install the SDKs

Install the SDKs for the APIs you plan to use.

# Responses and Chat Completions APIs (OpenAI SDK) pip install -U openai aws-bedrock-token-generator # Converse and InvokeModel APIs (AWS SDK for Python) pip install -U boto3

Model IDs and endpoint

Use an inference profile ID, not the base model ID, in all API calls. The base model ID amazon.ergo-1.0 cannot be called directly.

Inference profile ID Regions served
global.amazon.ergo-1.0 Any commercial AWS Region
us.amazon.ergo-1.0 US Regions only

The endpoint URL is https://bedrock-runtime.<region>.amazonaws.com. The examples in this topic use us-west-2.

Note

Amazon Ergo-1.0 always reasons. A reasoning effort of none returns a 400 error. Set an output limit of at least 8,192 tokens. Amazon Ergo-1.0 uses some of that limit for reasoning before it answers.

Set up OpenCode with Amazon Ergo-1.0

OpenCode (opencode.ai) uses the Chat Completions API to connect directly to Amazon Bedrock.

To set up OpenCode with Amazon Ergo-1.0
  1. Install OpenCode from opencode.ai.

  2. Add Amazon Ergo-1.0 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" }

    Each request reserves its full output limit against your account's quota, so keep limit.output close to what you need.

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

Set up Codex CLI with Amazon Ergo-1.0

Codex CLI (@openai/codex) uses the Responses API to connect directly to Amazon Bedrock.

To set up Codex CLI with Amazon Ergo-1.0
  1. Install Codex CLI:

    npm i -g @openai/codex

    Alternatively, install with Homebrew: brew install codex.

  2. Add the following to ~/.codex/config.toml:

    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 ~/.zshrc or ~/.bashrc. Codex does not read the Region from the AWS CLI profile.

  3. Run codex in your project folder, or run codex exec "your prompt". Add --skip-git-repo-check outside a git repo or trusted folder.

Note

Codex might print "Model metadata for global.amazon.ergo-1.0 not found" at startup. You can ignore this message.

Set up Claude Code with Amazon Ergo-1.0

Claude Code uses the Anthropic Messages API. To use it with Amazon Ergo-1.0, run a local LiteLLM proxy. The proxy translates Claude Code requests into Amazon Bedrock Responses API calls.

To set up Claude Code with Amazon Ergo-1.0
  1. Install Claude Code from code.claude.com and install uv from docs.astral.sh/uv.

  2. Save the following LiteLLM configuration 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

    The value sk-ergo-local is a user-chosen local placeholder string for the proxy, not a real credential. You can use any string as long as the value here matches ANTHROPIC_AUTH_TOKEN in the launcher script in the following step. The proxy reads AWS_BEARER_TOKEN_BEDROCK at startup; restart the proxy after a key change.

  3. Start the LiteLLM proxy:

    uv tool run --from 'litellm[proxy]' litellm \ --config ~/ergo-claude-code/litellm.yaml --host 127.0.0.1 --port 4000
  4. Save the following launcher script as ~/ergo-claude-code/claude-ergo and make it executable with chmod +x ~/ergo-claude-code/claude-ergo:

    #!/usr/bin/env bash export ANTHROPIC_BASE_URL="http://127.0.0.1:4000" export ANTHROPIC_AUTH_TOKEN="sk-ergo-local" # must match master_key in litellm.yaml 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 "$@"
  5. Run ~/ergo-claude-code/claude-ergo in your project folder.

Note

If ~/.claude/settings.json has an env block that sets CLAUDE_CODE_USE_BEDROCK or ANTHROPIC_MODEL, those values override the launcher. Use --setting-sources project,local to skip user settings.

Troubleshooting

Use the following table to diagnose common errors.

Error Fix
400 Invocation of model ID amazon.ergo-1.0 with in-region isn't supported Use global.amazon.ergo-1.0 or us.amazon.ergo-1.0 instead of the base model ID.
400 The provided model identifier is invalid Call from a supported Region, and confirm that your account has access to Amazon Ergo-1.0.
403 AccessDeniedException Add the permissions in the IAM permissions step to the IAM identity, or to the IAM user associated with your API key.
403 UnrecognizedClientException Confirm that AWS_BEARER_TOKEN_BEDROCK is set and the key hasn't expired.
429 ThrottlingException Your account's quota is used up. Retry later, lower the output limit, or request a quota increase.
Empty answer (finish_reason: "length", status: "incomplete", stopReason: "max_tokens") Raise the output limit to at least 8,192 tokens.
Codex: error about the web_search tool Set web_search = "disabled" in config.toml.
Codex: Amazon Bedrock bearer token auth requires ... AWS_REGION Set AWS_REGION to the Region in base_url (see the Codex CLI section).
Claude Code: authentication error from the proxy Confirm that ANTHROPIC_AUTH_TOKEN matches master_key in litellm.yaml.