Use MagmaRouter in OpenCode.
OpenCode defines providers in opencode.json using the AI SDK provider packages. Add MagmaRouter with the openai-compatible package and point it at the /v1 base URL.
Add a provider in opencode.json
In ~/.config/opencode/opencode.json or a project opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"magmarouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "MagmaRouter",
"options": {
"baseURL": "https://magmarouter.com/v1",
"apiKey": "{env:MAGMAROUTER_API_KEY}"
},
"models": {
"deepseek/deepseek-chat-v3.1": {
"name": "DeepSeek Chat v3.1",
"limit": { "context": 163840, "output": 8192 }
}
}
}
},
"model": "magmarouter/deepseek/deepseek-chat-v3.1",
"small_model": "magmarouter/deepseek/deepseek-chat-v3.1"
}
Set the real context and output limits from the model's catalogue page. For an agent that edits files, choose a tool-capable model. You can also run /connect in OpenCode, choose Other, and paste the key against a provider id of magmarouter.