OpenCode
Add a custom OpenCode provider, connect its credentials, and select its model.
Install and prepare
- Install OpenCode using its official npm package below, then run
opencode --version. Node.js and npm must be available. - Create a routerra.ai key under API Keys. Copy a model ID permitted for that key from Models; the example uses the Chat Completions protocol and requires tool-call support for coding tasks.
npm install -g opencode-ai
opencode --version
Register and connect routerra
- Create or merge
opencode.jsonin the project root. For all projects, use~/.config/opencode/opencode.jsoninstead. Replace everyYOUR_MODEL_IDconsistently;routerra/is OpenCode’s provider prefix, not part of the upstream model ID. - Start
opencode, run/connect, choose Other, enter provider IDrouterra, and paste your key. The ID must exactly match the JSON object key. Credentials are stored separately in~/.local/share/opencode/auth.json. Run/modelsand select the configured model. Restart OpenCode after changing the configuration file.
{
"$schema": "https://opencode.ai/config.json",
"model": "routerra/YOUR_MODEL_ID",
"provider": {
"routerra": {
"npm": "@ai-sdk/openai-compatible",
"name": "routerra.ai",
"options": { "baseURL": "https://routerra.ai/v1" },
"models": { "YOUR_MODEL_ID": { "name": "YOUR_MODEL_ID" } }
}
}
}
Check the connection
If the provider is missing, check which project/global config was loaded and whether provider.routerra.models is present. A saved key under a different /connect ID cannot authenticate this provider. For a /responses-only model, change npm to @ai-sdk/openai; the shown @ai-sdk/openai-compatible calls /chat/completions. Test a short reply and a read-only file query, then inspect routerra.ai usage for the chosen model.