Integration · SST

Use Crazyrouter models in OpenCode

OpenCode's provider system takes any OpenAI-compatible endpoint. The setup script writes the provider block, a curated model list and sensible defaults, then verifies the key.

One-command setup

The script is idempotent — re-run it to change the default model. Add more models by extending the models map; names must match the Crazyrouter catalogue.

  1. 1Run the command

    Pulls the script from GitHub; nothing else is downloaded.

  2. 2Paste your Crazyrouter key

    Pick a default model when asked; you can change it later.

  3. 3Tool talks to Crazyrouter

    Config or env vars are written; the next launch routes through your key.

macOS / Linux
curl -fsSL https://raw.githubusercontent.com/xujfcn/opencode-crazyrouter/main/setup.sh | bash
What the script does
  • Checks that opencode, curl and python3 are present
  • Adds a crazyrouter provider to ~/.config/opencode/opencode.json with a preloaded model list
  • Sets the default and small model, then calls /v1/models to verify the key
  • Non-interactive: bash <(curl -fsSL …/setup.sh) --yes --model claude-sonnet-4-6

Scripts are fetched from the public GitHub repo linked below. Read them before piping to a shell if that's your policy; the download-then-run form is in the README.

Manual configuration

~/.config/opencode/opencode.json

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "crazyrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Crazyrouter",
      "options": { "baseURL": "https://api.crazyrouter.com/v1", "apiKey": "sk-your-crazyrouter-key" },
      "models": {
        "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
        "claude-opus-4-8": { "name": "Claude Opus 4.8" },
        "gpt-5.5": { "name": "GPT-5.5" },
        "deepseek-v4-flash": { "name": "DeepSeek V4 Flash" }
      }
    }
  },
  "model": "crazyrouter/claude-sonnet-4-6",
  "small_model": "crazyrouter/deepseek-v4-flash"
}
Base URL rule

https://api.crazyrouter.com/v1 — This tool is OpenAI-compatible and appends /chat/completions (or /responses) itself. Use the /v1 base URL exactly as shown.

Recommended models

Live Crazyrouter prices, refreshed hourly. Any model in the catalogue works; these are the ones we'd start with.

FAQ

What is small_model for?

OpenCode uses it for cheap internal tasks like titles and summaries; deepseek-v4-flash keeps that cost near zero.

Why @ai-sdk/openai-compatible?

It's the provider adapter OpenCode uses for any OpenAI-shaped endpoint; Crazyrouter speaks that protocol.

Can I keep other providers?

Yes — the script only adds the crazyrouter key under provider and updates model / small_model.