Agents & CLIsReference / 19

OpenCode

Add RouterPlex as a custom provider in OpenCode.

Follow updates Share setup

Add RouterPlex as a custom provider in ~/.config/opencode/opencode.json (or a per-project opencode.json):

json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"routerplex": {
"npm": "@ai-sdk/openai-compatible",
"name": "RouterPlex",
"options": {
"baseURL": "https://api.routerplex.com/v1",
"apiKey": "{env:ROUTERPLEX_API_KEY}"
},
"models": {
"claude-opus-4-8": { "name": "Claude Opus 4.8" },
"gpt-5.5": { "name": "GPT-5.5" },
"kimi-k2.7": { "name": "Kimi K2.7" }
}
}
}
}

Then pick the model inside OpenCode with /models.

Verify the provider #

Start OpenCode, open the model picker, and confirm the RouterPlex models from the configuration appear under the RouterPlex provider. Run one small repository question before changing a production workflow. A 401 response means the environment variable is missing or the key is invalid; a model-not-found response usually means the configured model ID does not exactly match the RouterPlex model catalog.

Control agent spend #

Use a dedicated RouterPlex key for OpenCode instead of sharing a production key. Set a hard budget and, if appropriate, allowlist only the models included in the OpenCode configuration. This keeps project usage attributable and limits the cost of an accidental agent loop. Add or remove models in the configuration as your workflow changes; the base URL and authentication remain the same.

OpenCode — Docs