blackrouter
sign in create account

opencode

through chat completions · /v1/chat/completions · every model blackrouter serves, with its price and context window

model

deepseek-v4.1-flash · $0.30 in · $1.20 out /m · 128K context (not stated: 128K taken)

  1. a key

    create an account, then make an api key on it: it is shown once, so keep it.

    the provider below reads it from BLACKROUTER_API_KEY.

    macos, linux
    export BLACKROUTER_API_KEY=brk-…
    windows
    setx BLACKROUTER_API_KEY brk-… (then a new terminal)
  2. add blackrouter as a provider

    ~/.config/opencode/opencode.json
    {
      "provider": {
        "blackrouter": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "blackrouter",
          "options": { "baseURL": "https://blackrouter.sh/v1", "apiKey": "{env:BLACKROUTER_API_KEY}" },
          "models": {
            "deepseek-v4.1-flash": {
              "name": "deepseek-v4.1-flash",
              "reasoning": true,
              "interleaved": { "field": "reasoning_content" },
              "tool_call": true,
              "temperature": true,
              "attachment": false,
              "modalities": { "input": ["text"], "output": ["text"] },
              "limit": { "context": 131072, "output": 32768 },
              "cost": { "input": 0.3, "output": 1.2, "cache_read": 0.006 }
            }
          }
        }
      }
    }

    beside what opencode.json holds already · opencode 1 and 2 · one entry under "models" for each id you want, the same way

    windows and prices
    opencode compacts in time, and shows what a session cost at today's prices
    reasoning
    sent back on tool turns, as kimi- and deepseek-style models need
  3. use it

    terminal
    opencode -m blackrouter/deepseek-v4.1-flash

    /models switches to any id in the provider, under blackrouter

other ways

take "blackrouter" out of "provider" in opencode.json