Skip to content

Connecting OpenCode

OpenCode is an open-source agentic coding CLI. It works with NordRouter through the OpenAI-compatible endpoint.

Config

Open ~/.config/opencode/opencode.json (create it if missing) and add the provider:

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "nordrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "NordRouter",
      "options": {
        "baseURL": "https://nordrouter.com/v1",
        "apiKey": "sk-nr-YOUR-KEY"
      },
      "models": {
        "anthropic/claude-sonnet-4.6": { "name": "Claude Sonnet 4.6" },
        "anthropic/claude-opus-4.8": { "name": "Claude Opus 4.8" },
        "openai/gpt-5.5": { "name": "GPT-5.5" },
        "deepseek/deepseek-v4-flash": { "name": "DeepSeek V4 Flash" }
      }
    }
  }
}

Paste your key from the dashboard, run opencode and pick a model via /models.

Caching works automatically

OpenCode keeps a stable session context, so Claude models via NordRouter cache on their own — repeated passes over the same context are up to 90% cheaper. Nothing to configure.

Which models to add

You can put any model from the catalog into the models block — the ID is copied as-is. Popular picks for coding:

  • anthropic/claude-sonnet-4.6 — price/quality balance;
  • anthropic/claude-opus-4.8 / anthropic/claude-sonnet-5 — maximum quality;
  • deepseek/deepseek-v4-flash — cheap for routine work;
  • z-ai/glm-5.2 — a strong Chinese coding model.

If it doesn't work

See troubleshooting — all the typical cases with fixes.