OpenCode + minirouter
Draft provider block for registering minirouter in OpenCode's JSON configuration.
Settings
opencode.json — project root, or ~/.config/opencode/opencode.json
In order
- Config fileopencode.json
Use the draft block below as a starting point, then verify it against the installed version.
- Environmentexport MINIROUTER_KEY=mr-live-…
The config reads the key from this env var.
- Pick a model/models → minirouter
Inside OpenCode, /models lists the provider's models.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"minirouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "minirouter",
"options": {
"baseURL": "https://api.minirouter.sh/v1",
"apiKey": "{env:MINIROUTER_KEY}"
},
"models": {
"meta/llama-3.3-70b": { "name": "Llama 3.3 70B" },
"mistral/devstral-small-2": { "name": "Devstral Small 2" },
"deepseek/deepseek-v3": { "name": "DeepSeek V3" },
"meta/llama-4-maverick": { "name": "Llama 4 Maverick" }
}
}
}
}Draft candidates · 4 models
All models →- Modelmistral/devstral-small-2WhyCoding-oriented candidate for edits and tool calls.→
- Modelmeta/llama-3.3-70bWhyGeneral-purpose candidate for agent tasks.→
- Modeldeepseek/deepseek-v3WhyReasoning-oriented candidate for multi-step work.→
- Modelmeta/llama-4-maverickWhyLong-context candidate for larger repositories.→
Only rows confirmed in the current live catalog are linked. A plain row is a draft recommendation, not a claim that the model is currently available. Paste ids exactly as written, author/name.
When it fails
- Symptom404, HTML, or a parse error on every requestCodeinvalid_request
Almost always the base URL. Use https://api.minirouter.sh/v1 — the bare host without /v1 also works, but never append /chat/completions to the base URL field; the client adds that path itself. docs/errors#invalid_request →
- Symptom401 on every requestCodeinvalid_api_key
Wrong or rotated key. Keys start with mr-live-; after a rotation the old key keeps working for 24 hours, then dies. docs/errors#invalid_api_key →
- Symptom402 before any tokens arriveCodeinsufficient_credits
Balance below the estimated cost of the request. Top up ($5 minimum) — and watch the x-minirouter-balance-usd header, the low-balance signal every response carries. docs/errors#insufficient_credits →
- SymptomProvider missing from /modelsCodeclient-side
OpenCode merges project and global config; a JSON syntax error makes the whole provider block vanish silently. Validate the file, then restart OpenCode.
Every API error string carries a URL resolving to /docs/errors.