Use OpenCode with the Gateway¶
OpenCode is an open-source terminal coding agent that supports multiple AI providers. Connect it to the Gateway to use Claude and other models through your regional endpoint.
Prerequisites¶
- OpenCode installed:
curl -fsSL https://opencode.ai/install | bashornpm i -g opencode-ai - An LLM API key
Set your API key¶
Add to your shell profile (~/.zshrc, ~/.bashrc, or ~/.config/fish/config.fish):
export AMAZEEAI_API_KEY="your-api-key-here"
Then reload your shell:
source ~/.zshrc # or ~/.bashrc
Connect OpenCode to the Gateway¶
Create ~/.config/opencode/opencode.json (all projects) or opencode.json in your project root (one project):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"amazeeai": {
"npm": "@ai-sdk/openai-compatible",
"name": "Gateway",
"options": {
"baseURL": "https://llm.[your-region].amazee.ai/v1",
"apiKey": "{env:AMAZEEAI_API_KEY}"
},
"models": {
"claude-4-5-sonnet": { "name": "Claude Sonnet 4.5" },
"claude-4-5-haiku": { "name": "Claude Haiku 4.5" }
}
}
},
"model": "amazeeai/claude-4-5-sonnet",
"small_model": "amazeeai/claude-4-5-haiku"
}
Replace [your-region] with your region code (e.g. ch103, us103).
OpenCode only shows the models you list under models. It doesn't read the Gateway's model list. To add a model, copy its exact ID from Available Models or /v1/models. Set small_model too: OpenCode uses it for things like session titles.
Check it's using the Gateway¶
OpenCode falls back to its own hosted models
If OpenCode can't find or read your config, it doesn't show an error. It sends your prompts to OpenCode's own free models instead of the Gateway. Check before you work on real code.
opencode models amazeeai
You should see the models you listed. Then run:
opencode run "say hi"
The header line should show claude-4-5-sonnet. If it shows big-pickle or another opencode/... model, your config wasn't loaded.
Start OpenCode¶
cd /path/to/your/project
opencode
Switching models¶
Pick a model with /models inside OpenCode, or pass -m amazeeai/<model-id>. Only models listed in your models block appear.
Troubleshooting¶
- Answers come back but nothing shows in your usage
- OpenCode isn't reading your config and fell back to its own models. Check the file is named
opencode.json(no leading dot) and is in~/.config/opencode/or your project root. - "Model not found" or "Unexpected server error"
- The model ID isn't in your
modelsblock, or doesn't match the Gateway's ID exactly. Gateway IDs look likeclaude-4-5-sonnet, notclaude-sonnet-4-5. - Auth errors
- Run
echo $AMAZEEAI_API_KEYin the same shell you start OpenCode from. - "team not allowed to access model"
- Your key doesn't include that model. Pick one your
/v1/modelscall returns.