Amazon Ergo API: a practical guide with code examples
Updated December 4, 2026 · 8 min read · Tested against Amazon Bedrock
https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1, with model ID global.amazon.ergo-1.0. Authenticate with a Bedrock API key (Bearer token) or IAM access keys (SigV4). Use reasoning_effort to control thinking, and set max_completion_tokens high enough to leave room for reasoning.What you need
| Setting | Value |
|---|---|
| Endpoint | https://bedrock-runtime.<region>.amazonaws.com/openai/v1/chat/completions |
| Model ID (global routing) | global.amazon.ergo-1.0: $1 / $3 per 1M tokens |
| Model ID (US only) | us.amazon.ergo-1.0: $1.10 / $3.30 per 1M tokens |
| Auth option A | Bedrock API key, sent as Authorization: Bearer … |
| Auth option B | IAM access key + secret, signed with AWS SigV4 (service bedrock) |
| Request format | OpenAI Chat Completions (messages, stream, tools) |
To get a Bedrock API key, open the Amazon Bedrock console, go to API keys and generate a long-term key. Keep it on your server only, never in browser or mobile code. Ergo is offered through cross-region inference, so use the global. or us. model ID rather than a plain model name.
Quick test with curl
curl https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions \
-H "Authorization: Bearer $AWS_BEARER_TOKEN_BEDROCK" \
-H "Content-Type: application/json" \
-d '{
"model": "global.amazon.ergo-1.0",
"messages": [{"role": "user", "content": "Write a haiku about servers"}],
"reasoning_effort": "low",
"max_completion_tokens": 8192
}'
If you get JSON with choices[0].message.content, you're set. Even at "low" effort, Ergo thinks before answering: in our test a two-word reply used 64 reasoning tokens, which are billed as output.
Python (OpenAI SDK)
Because the endpoint is OpenAI-compatible, the official openai package works with a different base URL:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1",
api_key=os.environ["AWS_BEARER_TOKEN_BEDROCK"], # your Bedrock API key
)
stream = client.chat.completions.create(
model="global.amazon.ergo-1.0",
messages=[{"role": "user", "content": "Explain recursion with a short Python example"}],
reasoning_effort="medium",
max_completion_tokens=16000,
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Node.js / TypeScript (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1",
apiKey: process.env.AWS_BEARER_TOKEN_BEDROCK, // your Bedrock API key
});
const res = await client.chat.completions.create({
model: "global.amazon.ergo-1.0",
messages: [{ role: "user", content: "Write a debounce function in TypeScript" }],
reasoning_effort: "medium",
max_completion_tokens: 16000,
});
console.log(res.choices[0].message.content);
Using IAM access keys (SigV4) instead of an API key
Some AWS accounts can't use Bedrock API keys at all, usually because they belong to an AWS Organization whose policy blocks them (see errors below). In that case, sign requests with normal IAM access keys. Create an IAM user with the AmazonBedrockLimitedAccess policy (or bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream), then create an access key for "Application running outside AWS".
curl can sign the request for you:
curl https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions \
--aws-sigv4 "aws:amz:us-east-1:bedrock" \
--user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "global.amazon.ergo-1.0",
"messages": [{"role": "user", "content": "Say hi"}],
"reasoning_effort": "low",
"max_completion_tokens": 8192
}'
In Python, botocore does the signing:
import json, os, requests
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
from botocore.credentials import Credentials
url = "https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions"
body = json.dumps({
"model": "global.amazon.ergo-1.0",
"messages": [{"role": "user", "content": "Say hi"}],
"reasoning_effort": "low",
"max_completion_tokens": 8192,
})
creds = Credentials(os.environ["AWS_ACCESS_KEY_ID"], os.environ["AWS_SECRET_ACCESS_KEY"])
req = AWSRequest(method="POST", url=url, data=body, headers={"Content-Type": "application/json"})
SigV4Auth(creds, "bedrock", "us-east-1").add_auth(req) # service name is "bedrock"
r = requests.post(url, data=body, headers=dict(req.headers))
print(r.json()["choices"][0]["message"]["content"])
The OpenAI endpoint accepts the same SigV4-signed requests as the rest of Bedrock, so streaming and tool calling work the same way.
Parameters that matter
| Parameter | What to know |
|---|---|
reasoning_effort | low, medium, high, xhigh or max. Higher means better answers on hard tasks but more time and more output tokens. Ergo always reasons, so "none" isn't accepted. |
max_completion_tokens | Covers reasoning plus the answer, up to 131,072. Leave plenty of room (8,192 or more): a low limit can be used up by reasoning before the answer is written. |
stream | Streams Server-Sent Events like OpenAI. Add "stream_options": {"include_usage": true} to get token counts at the end. |
tools | OpenAI-style function calling, see below. |
| Context | Up to 1,048,576 tokens of input. Text only: image inputs aren't supported. |
Tool calling
Send tools in the standard OpenAI format. When Ergo wants to call one, the response has finish_reason: "tool_calls" and a tool_calls array. Run the tool, append a role: "tool" message with the matching tool_call_id, and call the endpoint again.
{
"model": "global.amazon.ergo-1.0",
"messages": [{"role": "user", "content": "What's the weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}],
"tool_choice": "auto",
"max_completion_tokens": 8192
}
Agents built this way can run many steps in a row. Ergo AI uses exactly this loop to plan, write files and check its work.
Common errors and fixes
"not authorized to perform: bedrock:CallWithBearerToken … explicit deny in a service control policy"
User: arn:aws:iam::123456789012:user/... is not authorized to perform: bedrock:CallWithBearerToken on resource: * with an explicit deny in a service control policy
Your AWS account is a member of an AWS Organization whose service control policy blocks Bedrock API keys. No permission inside your own account can override an explicit deny. Either ask whoever manages the organization to remove that deny, or switch to IAM access keys with SigV4: the policy blocks bearer tokens, not signed requests, so the same call works.
The Mantle endpoint doesn't list Ergo
Bedrock's newer OpenAI-compatible endpoint, bedrock-mantle.<region>.api.aws/v1, accepts Bedrock API keys and lists many models, but when we checked on December 4, 2026, Amazon Ergo wasn't among them. Use the bedrock-runtime endpoint above for Ergo.
Empty or cut-off answers
Raise max_completion_tokens. Reasoning tokens come out of the same budget, so at high or max effort a small limit can run out before the visible answer starts.
"The server had an error while processing your request"
Usually brief. Retry once after a second or two, and keep a backup model for production traffic.
An easier option: the Ergo AI API
If you don't want to manage AWS accounts, keys and SigV4 signing, the Ergo AI API is also OpenAI-compatible and runs on Amazon's Ergo model, with automatic retries and a backup model if Ergo is down. It's included with Ergo AI plans.
FAQ
What is the Amazon Ergo model ID on Bedrock?
Use global.amazon.ergo-1.0 for global cross-region inference ($1 / $3 per million tokens) or us.amazon.ergo-1.0 to keep requests in the US ($1.10 / $3.30).
Does Amazon Ergo work with the OpenAI SDK?
Yes. Point the OpenAI SDK at https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1 and use a Bedrock API key as the API key. Chat Completions, streaming and tool calling all use the OpenAI format.
Does Amazon Ergo support function calling?
Yes. On Amazon Bedrock, Ergo accepts OpenAI-style tools and returns tool_calls, so it can run multi-step agent loops.
Why do I get CallWithBearerToken explicit deny?
Your AWS account is in an AWS Organization whose service control policy blocks Bedrock API keys. Use IAM access keys with SigV4 signing instead, or ask the organization's admin to remove the deny.
What reasoning effort should I use with Amazon Ergo?
Start with medium for most coding and chat. Use low for quick, simple replies, and high, xhigh or max for hard, multi-step work. Higher effort costs more output tokens and takes longer.
Ergo AI (ergoai.dev) is an independent product that uses Amazon's Ergo model through AWS Bedrock. It is not made by, affiliated with, or endorsed by Amazon. "Amazon" and "Amazon Ergo" belong to their respective owners.