1. Add the Bedrock Ergo provider to opencode.json
OpenCode connects natively to Amazon Bedrock’s OpenAI-compatible endpoint with no local proxy required. Export AWS_BEARER_TOKEN_BEDROCK in your shell, then merge this provider block into ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"bedrock-ergo": {
"npm": "@ai-sdk/openai-compatible",
"name": "Amazon Bedrock Ergo",
"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": "Amazon Ergo 1.0",
"limit": {
"context": 1048568,
"output": 16384
}
}
}
}
}
}
2. Select Ergo and verify your first run
- Run
opencodein a small test repository. - Type
/modelsand choose Amazon Bedrock Ergo → Amazon Ergo 1.0. - Run a read-only question first (for example, asking it to map test coverage gaps) and confirm the request appears in your AWS Bedrock usage dashboard.
Tuning output limits & troubleshooting
- Raising output limits: Ergo supports up to 128,000 output tokens, though starting at
8192or16384keeps runaway loops from burning unnecessary reasoning tokens while you evaluate. - US-only data residency: Swap
"global.amazon.ergo-1.0"for"us.amazon.ergo-1.0"(10% higher Bedrock token rates). - 403 / Validation errors: Confirm
AWS_BEARER_TOKEN_BEDROCKis exported in the same shell where you runopencodeand that your AWS policy allows cross-Region profile invocation inus-west-2.
Resources: AWS Ergo coding-tool docs · API cost calculator · All setup guides.
Frequently asked questions
Do I need a LiteLLM proxy to use Amazon Ergo in OpenCode?
No. OpenCode uses @ai-sdk/openai-compatible to talk directly to Bedrock’s /openai/v1 endpoint, so you only need opencode.json and AWS_BEARER_TOKEN_BEDROCK.
Can I raise the output token limit above 16,384 in opencode.json?
Yes. Amazon Ergo-1.0 supports up to 128,000 output tokens. Starting at 8,192 or 16,384 in opencode.json is a practical guardrail while testing new agent loops.
How do I switch OpenCode from Global to US-only Bedrock routing?
Replace global.amazon.ergo-1.0 with us.amazon.ergo-1.0 in your models object to restrict inference to U.S. Regions.