OpenCode is an open-source coding agent for the terminal. Add Yunshu Router as a provider in
opencode.json and OpenCode runs on the model you choose, billed per token to your prepaid
balance.
What you need
- OpenCode installed.
- A Yunshu Router account with credit on the balance.
- An API key from the console. Use a separate key for OpenCode.
Set it up
-
Create a key in the console (API keys → Create key) and copy it.
-
{ "$schema": "https://opencode.ai/config.json", "providers": { "yunshu": { "package": "@opencode/ai/providers/openai-compatible", "name": "Yunshu Router", "env": ["YUNSHU_API_KEY"], "settings": { "baseURL": "https://api.yunshurouter.com/v1" }, "models": { "deepseek-v4-pro": { "name": "DeepSeek V4 Pro", "limit": { "context": 131072, "output": 8192 } }, "kimi-k3": { "name": "Kimi K3", "limit": { "context": 262144, "output": 16384 } } } } }, "model": "yunshu/deepseek-v4-pro" }Field Why package: @opencode/ai/ providers/ openai-compatible Uses Chat Completions ( /).v1/ chat/ completions settings.baseURLWith /.v1 envThe environment variable OpenCode reads the key from, so it stays out of the file. modelsEach model you want in the picker. modelThe default, as provider/.model -
Give OpenCode the key. Either export it:
export YUNSHU_API_KEY="YOUR_YUNSHU_KEY"or run
/connectin OpenCode, choose Other, enteryunshuas the provider ID, and paste the key. OpenCode stores it in~/.local/share/opencode/auth.json. -
Start OpenCode in your project and run
/modelsto pick a Yunshu Router model.
Check it works
- Ask: “What does this repository do? Read the README first.”
- A correct answer after a file read means requests and tool calls work.
- Open Usage in the console: the requests show under the OpenCode key.
Recommended models
| Model ID | Use it for |
|---|---|
deepseek-v4-pro |
Build agent, everyday work |
kimi-k3 |
Plan agent, long tasks |
glm-5.3 |
Small model for titles and quick tasks |
Set a budget on the key
In the console, open API keys, pick the OpenCode key and set a monthly budget, a model
allow-list and a budget alert. A request that would pass the budget is refused with
402 budget_exceeded.
Known limitations
@opencode/ai/providers/openai-compatiblespeaks Chat Completions. OpenCode also has Responses packages, such as@opencode/ai/providers/openai-compatible/responses. You don’t need them with us, as every model is on Chat Completions.
Troubleshooting
| What you see | Likely cause | Fix |
|---|---|---|
Provider missing from / |
Provider ID in config differs from the one in / |
Use yunshu in both. |
401 |
Key not set, or wrong | echo $YUNSHU_, or run / again. |
404 on every request |
baseURL without / |
Use https:/. |
404 naming the model |
Model key in models differs from our ID |
Copy the ID from the models page. |
403 naming the model |
Not on the key’s allow-list | Add it to the key. |
402 |
Budget or balance used up | Raise the budget or top up. |
| Context runs out early | limit.context too low, or not set |
Set it from the model page. |