OpenCode
OpenCode can use a custom OpenAI-compatible provider. Configure a provider entry for OdiRouter, add an API key, and select the model in OpenCode.
Requirements
Section titled “Requirements”| Requirement | Value |
|---|---|
| OpenCode | Installed locally |
| Provider package | @ai-sdk/openai-compatible |
| Base URL | https://www.odirouter.ai/v1 |
| API Key | OdiRouter API key |
| Model | An OdiRouter LLM model ID |
Install OpenCode
Section titled “Install OpenCode”If OpenCode is not installed yet, install it with npm:
npm install -g opencode-aiYou can also install the CLI package name:
npm install -g @opencode-ai/cliIf you installed OpenCode through the official installer, Homebrew, or another method, just confirm the command is available:
opencode --versionAdd The API Key
Section titled “Add The API Key”Start OpenCode from your project directory:
opencodeInside OpenCode, run:
/connectWhen adding the credential, use:
| Field | Value |
|---|---|
| Provider ID | odirouter |
| API Key | YOUR_API_KEY |
The provider ID must match provider.odirouter in opencode.json.
Configure The Provider
Section titled “Configure The Provider”Create or edit opencode.json in your project:
{ "$schema": "https://opencode.ai/config.json", "provider": { "odirouter": { "npm": "@ai-sdk/openai-compatible", "name": "OdiRouter", "options": { "baseURL": "https://www.odirouter.ai/v1" }, "models": { "gpt-5.5": { "name": "GPT 5.5" } } } }, "model": "odirouter/gpt-5.5"}Start OpenCode
Section titled “Start OpenCode”cd /path/to/your/projectopencodeInside OpenCode, run:
/modelsSelect the OdiRouter model if it is not already active.
Verify The Connection
Section titled “Verify The Connection”Explain this project structure. Do not edit files.Troubleshooting
Section titled “Troubleshooting”| Symptom | Fix |
|---|---|
| Provider does not appear | Restart OpenCode after editing opencode.json |
| Authentication fails | Re-run /connect and use the same provider ID as the config |
| Model not found | Copy a model ID from GET https://www.odirouter.ai/v1/models |
| Config is ignored | Start OpenCode from the directory that contains opencode.json, or set OPENCODE_CONFIG to the config path |