OpenCode
OpenCode is an open-source command-line coding assistant. Through the OpenAI-compatible API it can use any CodingRouter text model.
Preparation
- Install OpenCode:
npm install -g opencode-ai - Create a token, choosing the group for the model you want to use (for example
gptfor GPT,claudefor Claude).
Configuration
Edit ~/.config/opencode/opencode.json (to use it in one project only, put opencode.json in the project root):
json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"codingrouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "CodingRouter",
"options": {
"baseURL": "https://api.codingrouter.ai/v1",
"apiKey": "{env:CODINGROUTER_KEY}"
},
"models": {
"gpt-5.5": { "name": "GPT-5.5" },
"claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" }
}
}
}
}List the models you want in models. The names must match the model square and the models must be in the token's group.
Set the token and start:
bash
export CODINGROUTER_KEY="sk-your-token"
opencodeAfter starting, use /models to select a model under CodingRouter.
Verify
bash
opencode run -m codingrouter/gpt-5.5 "Reply with exactly: CODINGROUTER OK"Troubleshooting
| Symptom | What to do |
|---|---|
| HTML or 404 returned | baseURL must include /v1 |
| 503 | The model name is wrong, or the token's group does not contain this model |
| Using models from several vendors in one config | A token belongs to one group. Configure one provider per vendor, each with the token of the matching group |
