Search docs...

Start typing to search documentation

opencode
OpenCode

OpenCode Setup Guide

Add UnoRouter as a custom provider in OpenCode and pick any model as the active coding agent.

Overview

OpenCode reads its providers from a JSON config file. Add UnoRouter as a custom provider with the OpenAI-compatible adapter and you can pick any UnoRouter model as the active model.

Quick Config

Drop these values into the client. Your key auto-fills when you are signed in.

text
Base URL: https://api.unorouter.ai/v1
API Key: YOUR_API_KEY

Sign in to auto-fill your API key

Compatibility

Chat CompletionsStreamingTool calling

Step-by-step setup

  1. 1
    Open the OpenCode config file

    Press Ctrl + O inside OpenCode and paste the path. On Windows, replace YOUR_USER with your Windows username.

    text
    C:/Users/YOUR_USER/.config/opencode/opencode.json

    Sign in to auto-fill your API key

  2. 2
    Replace the file contents

    Wipe the file and paste the UnoRouter provider block. Drop in your UnoRouter API key and pick any model from the catalog.

    json
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "unorouter": {
          "name": "UnoRouter",
          "npm": "@ai-sdk/openai-compatible",
          "options": {
            "apiKey": "YOUR_API_KEY",
            "baseURL": "https://api.unorouter.ai/v1"
          }
        }
      }
    }

    Sign in to auto-fill your API key

  3. 3
    Save and reload

    Press Ctrl + S to save, then Ctrl + Shift + P and run Developer: Reload Window. OpenCode picks up the new provider on reload.

  4. 4
    Pick a model

    Open the model picker in OpenCode and switch to the model you added. The OpenAI-compatible adapter handles streaming and tool calling automatically.

Recommended models

Free models that work well here. Paste any model id into the client.

mistral-small-2506gemini-flash-latestmagistral-medium-2509magistral-small-2509allam-2-7b

Gotchas

  • OpenCode uses the npm @ai-sdk/openai-compatible adapter under the hood, so you can keep adding models under "models" without restarting.
  • If Developer: Reload Window does not show your provider, double check the JSON saved without trailing commas.
  • Use exact model ids from the UnoRouter catalog. Strip any leading provider prefix if a copy-paste added one.
Generate API KeyModels