Integrations
OpenCode
OpenCode is an open-source terminal coding agent that can hold several models in one config and switch between them at any time. It connects to FlyRouter over the OpenAI-compatible protocol, so Claude, GPT and other models all work.
Install
Follow the instructions on the OpenCode website, then run opencode in a terminal.
Set up FlyRouter
Set the API key
export FLYROUTER_API_KEY="sk-..."Add a provider
Edit the global config ~/.config/opencode/opencode.json (or an opencode.json in your project root, which takes precedence):
{
"$schema": "https://opencode.ai/config.json",
"model": "flyrouter/claude-sonnet-5-5",
"provider": {
"flyrouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "FlyRouter",
"options": {
"baseURL": "https://api.flyrouter.ai/v1",
"apiKey": "{env:FLYROUTER_API_KEY}"
},
"models": {
"claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" },
"claude-opus-5-5": { "name": "Claude Opus 5.5" },
"gpt-6.1-sol": { "name": "GPT-6.1 Sol" }
}
}
}
}The keys under models are model IDs; add or remove them as needed. name is the label shown in the UI.
Pick a model
Start opencode and type /models to see the FlyRouter models. The top-level model field sets the default, in the form provider/model-id.
Set the key with a command
If you'd rather not reference an environment variable in the config, run /connect in OpenCode, choose Other, enter flyrouter as the provider ID and paste your key. The key is stored in OpenCode's local credentials, and you can remove the apiKey line from the config.
Troubleshooting
- Empty model list: make sure
opencode.jsonis valid JSON (no trailing commas). - 401:
FLYROUTER_API_KEYisn't set, or the variable name in{env:...}is wrong. A missing variable becomes an empty string. - 404:
baseURLmust include/v1.