rk_ key, OPENAI_API_BASE, and any model id that starts with route/.
Official install and usage guides live at opencode.ai/docs.
Install OpenCode
Pick one install path, then confirm the binary is on yourPATH:
opencode --help (or opencode) from a project directory. If you use OpenCode’s own Zen or other hosted auth flows, skip those for routing.run and use the env vars in Connect routing.run below instead.
Connect routing.run
Get your API key
Create an API key at app.routing.run. Copy the full secret — it starts with
rk_.Apply environment variables
Use the Connection prompt block in the next section. Run the
export lines in the same shell where you start opencode, or add them to ~/.zshrc / ~/.bashrc / your CI secret store.Connection prompt
OpenCode readsOPENAI_API_KEY and OPENAI_API_BASE (not OPENAI_BASE_URL). Use Copy on the block below for a complete integration checklist.
OpenCode CLI — connect to routing.run
Manual configuration
If you want to configure OpenCode manually instead of using the prompt above, export these exact values in the same shell where you runopencode:
routing.run so switching providers is simpler.
Use a model id with the route/ prefix, for example route/glm-5.1.
If list calls work but chat fails, confirm the model id includes the
route/ prefix and appears in authenticated GET https://api.routing.run/v1/models for your key.Verify
After exporting, you should see your allowed model ids (not only the public anonymous list):Troubleshooting
- Wrong host or 401 —
OPENAI_API_BASEmust be exactlyhttps://api.routing.run/v1with no trailing slash.OPENAI_BASE_URLalone is not what OpenCode reads. - Unknown model — Use ids from the models catalog and your authenticated list; typos in
route/…ids returnINVALID_MODELfrom the API. - Env not picked up — GUI terminals sometimes launch without your shell profile. Export again in that terminal session, or wrap
opencodein a small script that sources the same vars.
Recommended models
Plan tier and access are authoritative on GEThttps://api.routing.run/v1/models with your rk_ key. The full list is on the models page; common picks:
| Model | Use case |
|---|---|
route/deepseek-v3.2 | General-purpose chat (matches most doc examples) |
route/glm-5.1 | Reasoning and coding |
route/minimax-m2.7 | Long-context sessions |
route/kimi-k2.5 | Agentic and tool-heavy flows |
route/qwen3.6-plus-preview | Qwen3.6-class preview |
route/qwen3.5-plus | Qwen3.5 flagship |