OpenCode Setup Guide
OpenCode can connect Claude and GPT models from one configuration file.
| Model family | Base URL |
|---|---|
| Claude / Anthropic | https://api.codyrouter.com/v1 |
| GPT / OpenAI | https://api.codyrouter.com/v1 |
Configuration Files
Common OpenCode paths:
- Model config:
~/.config/opencode/opencode.jsonc - Auth config:
~/.local/share/opencode/auth.json
You can put the API key directly in options.apiKey in opencode.jsonc and keep auth.json as an empty object. Model IDs can use either provider/model-id or plain model-id.
jsonc
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.codyrouter.com/v1",
"apiKey": "YOUR_API_KEY"
},
"npm": "@ai-sdk/anthropic"
},
"openai": {
"options": {
"baseURL": "https://api.codyrouter.com/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"gpt-5.3-codex": {
"name": "GPT-5.3 Codex",
"limit": { "context": 400000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
}
}
}
}
}If ~/.local/share/opencode/auth.json exists and does not need credentials, keep it as:
json
{}Checklist
- Claude and GPT use
/v1. - Model IDs can be written as
openai/gpt-5.3-codexorgpt-5.3-codex, but the model name must match Model IDs. - JSON / JSONC syntax errors prevent OpenCode from loading the configuration.
Restart OpenCode after saving the configuration. If the model appears and replies to a test message, the setup is complete.