On this page
Integrations
OpenCode
Use every RelayRouter model as a custom provider inside the OpenCode coding agent.
OpenCode supports custom [OI]-compatible providers through the AI SDK. Add RelayRouter to your config, export a key, and pick a model.
1. Create a key
Open the API keys page, create a key, and copy the secret. Then export it in the shell where you run OpenCode:
export RELAY_API_KEY="sk-or-v1-..."2. Add the provider
Add this to opencode.json in your project, or to ~/.config/opencode/opencode.json for every project:
{ "$schema": "https://opencode.ai/config.json", "provider": { "relayrouter": { "npm": "@ai-sdk/openai-compatible", "name": "RelayRouter", "options": { "baseURL": "https://api.relayrouter.org/v1", "apiKey": "{env:RELAY_API_KEY}" }, "models": { "deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash" }, "gpt-6-sol": { "name": "GPT-6 Sol" }, "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" } } } }, "model": "relayrouter/deepseek-v4.1-flash"}Use exact catalog ids
Each key under
models must match an id from GET /v1/models. The display name can be anything. Add only the models you want in the picker.3. Run it
- 1
Start OpenCode
Runopencodein your project directory. - 2
Pick the provider
Run/modelsand choose arelayrouter/…model. - 3
Send a prompt
Tool calls and streaming use the standard chat completions endpoint.
If OpenCode cannot see the models, confirm the base URL ends in /v1 and that RELAY_API_KEY is set in the same shell. To use a different default, change the top-level model value.