# Getting started with Ergo 1.0 on Amazon Bedrock Ergo 1.0 is a reasoning model for text, available on the Amazon Bedrock Runtime endpoint. This guide covers: 1. [Prerequisites](#1-prerequisites): AWS account, IAM permissions and an API key 2. [Getting started with the APIs](#2-getting-started-with-the-apis): Responses, Chat Completions, Converse and InvokeModel 3. [Setting up coding harnesses](#3-setting-up-coding-harnesses): OpenCode, Codex CLI and Claude Code ## Model IDs and Regions Call Ergo 1.0 through a cross-Region inference profile: | Inference profile ID | Requests are served in | |---|---| | `global.amazon.ergo-1.0` | Any commercial AWS Region | | `us.amazon.ergo-1.0` | US Regions only | **Endpoint:** `https://bedrock-runtime..amazonaws.com`, where `` is the Region you call from. The examples use `us-west-2`. The base model ID `amazon.ergo-1.0` can't be called directly; use one of the profile IDs above. --- ## 1. Prerequisites ### 1.1 AWS account If you're new to AWS, [sign up for an AWS account](https://portal.aws.amazon.com/billing/signup). ### 1.2 IAM permissions The IAM identity that calls Ergo 1.0 needs these permissions: ```json { "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", "arn:aws:bedrock:::foundation-model/amazon.ergo-1.0" ] } ] } ``` The Converse API is authorized as `bedrock:InvokeModel`, and ConverseStream as `bedrock:InvokeModelWithResponseStream`. ### 1.3 API key 1. In the [Amazon Bedrock console](https://console.aws.amazon.com/bedrock/home#/api-keys/long-term/create), generate a **long-term API key**. Copy it straight away; it's shown only once. 2. Make sure the IAM user associated with the key has the permissions in step 1.2. 3. Store the key in an environment variable. Add it to `~/.zshrc` or `~/.bashrc`, then open a new terminal: ```bash export AWS_BEARER_TOKEN_BEDROCK="your-api-key" ``` The AWS SDKs, the OpenAI SDK examples and the harness setups in this guide all read the key from `AWS_BEARER_TOKEN_BEDROCK`, so it never needs to go in code or config files. **Alternative: short-term key from your AWS credentials.** If you'd rather not create a long-term key, the `aws-bedrock-token-generator` package creates a short-term API key from your existing AWS credentials (for example, an AWS CLI profile): ```python from aws_bedrock_token_generator import provide_token token = provide_token(region="us-west-2") ``` Short-term keys expire. Generate a new one when it does. ### 1.4 Install the SDKs You need Python 3. Install the packages for the APIs you plan to use: ```bash # 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 ``` --- ## 2. Getting started with the APIs Ergo 1.0 is available through four APIs on the Bedrock Runtime endpoint: | API | Request | |---|---| | Responses (OpenAI-compatible) | `POST /openai/v1/responses` with `"model": "global.amazon.ergo-1.0"` | | Chat Completions (OpenAI-compatible) | `POST /openai/v1/chat/completions` with `"model": "global.amazon.ergo-1.0"` | | Converse / ConverseStream | `POST /model/global.amazon.ergo-1.0/converse` (`/converse-stream`) | | InvokeModel | `POST /model/global.amazon.ergo-1.0/invoke` with a Chat Completions-style body | > **Set an output limit of at least 8,192 tokens.** Ergo 1.0 reasons before it answers, and reasoning tokens count toward > the output limit. A small limit can end before any answer text. Save any of the examples below as `bedrock-first-request.py`, and run it with `python bedrock-first-request.py`. ### Responses API ```python import os from openai import OpenAI region = "us-west-2" client = OpenAI( api_key=os.environ["AWS_BEARER_TOKEN_BEDROCK"], # or provide_token(region=region), see step 1.3 base_url=f"https://bedrock-runtime.{region}.amazonaws.com/openai/v1", ) resp = client.responses.create( model="global.amazon.ergo-1.0", input="Can you explain the features of Amazon Bedrock?", max_output_tokens=8192, ) print(resp.output_text) ``` ### Chat Completions API ```python import os from openai import OpenAI region = "us-west-2" client = OpenAI( api_key=os.environ["AWS_BEARER_TOKEN_BEDROCK"], base_url=f"https://bedrock-runtime.{region}.amazonaws.com/openai/v1", ) resp = client.chat.completions.create( model="global.amazon.ergo-1.0", messages=[{"role": "user", "content": "Can you explain the features of Amazon Bedrock?"}], max_completion_tokens=8192, ) print(resp.choices[0].message.content) ``` ### Converse API ```python import boto3 client = boto3.client("bedrock-runtime", region_name="us-west-2") response = client.converse( modelId="global.amazon.ergo-1.0", messages=[{"role": "user", "content": [{"text": "Can you explain the features of Amazon Bedrock?"}]}], inferenceConfig={"maxTokens": 8192}, ) # The assistant message holds a reasoning block followed by the answer text. for block in response["output"]["message"]["content"]: if "text" in block: print(block["text"]) ``` ### InvokeModel API ```python import json import boto3 client = boto3.client("bedrock-runtime", region_name="us-west-2") response = client.invoke_model( modelId="global.amazon.ergo-1.0", body=json.dumps({ "messages": [{"role": "user", "content": "Can you explain the features of Amazon Bedrock?"}], "max_tokens": 8192, }), ) print(json.loads(response["body"].read())) ``` boto3 uses `AWS_BEARER_TOKEN_BEDROCK` when it's set. Otherwise it uses your AWS credentials. ### Useful parameters | Parameter | Responses | Chat Completions | Converse | InvokeModel | |---|---|---|---|---| | Max output tokens | `max_output_tokens` | `max_completion_tokens` | `inferenceConfig.maxTokens` | `max_tokens` | | Reasoning effort (`low`, `medium`, `high`, `xhigh`, `max`) | `reasoning.effort` | `reasoning_effort` | `additionalModelRequestFields.reasoning_config` | — | | Streaming | `stream=True` | `stream=True` | `converse_stream()` | `invoke_model_with_response_stream()` | Ergo 1.0 always reasons, so a reasoning effort of `none` returns a 400 error. Ergo 1.0 has a context window of 1,000,000 tokens and a maximum output of 128,000 tokens. --- ## 3. Setting up coding harnesses Make sure `AWS_BEARER_TOKEN_BEDROCK` is set (step 1.3). OpenCode and Codex CLI connect to Ergo 1.0 directly. Claude Code uses the Anthropic Messages API, so it connects through a local LiteLLM proxy that translates its requests to the Responses API. | Harness | API it uses | Connection | |---|---|---| | OpenCode | Chat Completions | Direct | | Codex CLI | Responses | Direct | | Claude Code | Anthropic Messages, translated to Responses | Through a local LiteLLM proxy | ### 3.1 OpenCode 1. Install OpenCode: . 2. Add Ergo 1.0 to `~/.config/opencode/opencode.json`: ```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": 1000000, "output": 32000 }, "options": { "reasoningEffort": "medium" } } } } }, "model": "bedrock-runtime/global.amazon.ergo-1.0" } ``` 3. Run `opencode` in your project folder. To switch models, type `/models` and choose **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.2 Codex CLI 1. Install Codex CLI: `npm i -g @openai/codex` or `brew install codex`. 2. Add Ergo 1.0 to `~/.codex/config.toml`: ```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 = 1000000 [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" ``` Codex also needs `AWS_REGION` set to the Region in `base_url`. It doesn't read the Region from your AWS CLI profile. Add it next to your API key in `~/.zshrc` or `~/.bashrc`: ```bash export AWS_REGION=us-west-2 ``` 3. Run `codex` in your project folder, or `codex exec "your prompt"` for a one-off task. `codex exec` runs only inside a git repo or a folder you've trusted; elsewhere, add `--skip-git-repo-check`. Codex may print *"Model metadata for `global.amazon.ergo-1.0` not found"*. You can ignore it. ### 3.3 Claude Code 1. Install [Claude Code](https://code.claude.com/docs) and [uv](https://docs.astral.sh/uv/getting-started/installation/). 2. Save this LiteLLM config as `~/ergo-claude-code/litellm.yaml`: ```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 ``` 3. Start the proxy in a terminal you leave open: ```bash uv tool run --from 'litellm[proxy]' litellm \ --config ~/ergo-claude-code/litellm.yaml --host 127.0.0.1 --port 4000 ``` The proxy reads your API key when it starts, so restart it after you change the key. 4. Save this launcher as `~/ergo-claude-code/claude-ergo` and make it executable with `chmod +x`: ```bash #!/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="1000000" 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. If you already use Claude Code with Bedrock, check `~/.claude/settings.json` for an `env` block that sets `CLAUDE_CODE_USE_BEDROCK` or `ANTHROPIC_MODEL`. Those settings override the launcher, and Claude Code silently uses your usual model instead of Ergo 1.0. To skip your user settings for this session, run `~/ergo-claude-code/claude-ergo --setting-sources project,local`. --- ## Troubleshooting | Error | Fix | |---|---| | 400 `Invocation of model ID amazon.ergo-1.0 with on-demand throughput isn't supported` | Use `global.amazon.ergo-1.0` or `us.amazon.ergo-1.0` instead of the base model ID | | 403 `AccessDeniedException` | Add the permissions in step 1.2 to the IAM identity, or to the IAM user associated with your API key | | 403 `UnrecognizedClientException` | Check 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` (section 3.2) | | Claude Code: authentication error from the proxy | Make `ANTHROPIC_AUTH_TOKEN` match `master_key` in `litellm.yaml` |