Skip to content

Integrations / OpenCode

Use OpenCode with any model

Add Yunshu Router to OpenCode with one provider block in opencode.json. Key setup with /connect, model limits, checks and fixes.

Get an API key

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

  1. Create a key in the console (API keys → Create key) and copy it.

  2. {
      "$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.baseURL With /v1.
    env The environment variable OpenCode reads the key from, so it stays out of the file.
    models Each model you want in the picker.
    model The default, as provider/model.
  3. Give OpenCode the key. Either export it:

    export YUNSHU_API_KEY="YOUR_YUNSHU_KEY"

    or run /connect in OpenCode, choose Other, enter yunshu as the provider ID, and paste the key. OpenCode stores it in ~/.local/share/opencode/auth.json.

  4. Start OpenCode in your project and run /models to pick a Yunshu Router model.

Check it works

  1. Ask: “What does this repository do? Read the README first.”
  2. A correct answer after a file read means requests and tool calls work.
  3. Open Usage in the console: the requests show under the OpenCode key.
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-compatible speaks 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 /models Provider ID in config differs from the one in /connect Use yunshu in both.
401 Key not set, or wrong echo $YUNSHU_API_KEY, or run /connect again.
404 on every request baseURL without /v1 Use https://api.yunshurouter.com/v1.
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.

Questions

Do I have to list every model?

Yes.

Can I keep the key out of the config file?

Yes. Name the variable in env (YUNSHU_API_KEY), or use /connect.

Can I use Claude models through this provider?

Not yet. Claude models can’t be called today. Use the DeepSeek, GLM and Kimi models on the models page.