blackrouter
sign in create account

pi

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: pi lists its models once the key is set.

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

    ~/.pi/agent/models.json
    {
      "providers": {
        "blackrouter": {
          "name": "blackrouter",
          "baseUrl": "https://blackrouter.sh/v1",
          "api": "openai-completions",
          "apiKey": "$BLACKROUTER_API_KEY",
          "models": [
            {
              "id": "deepseek-v4.1-flash",
              "name": "deepseek-v4.1-flash",
              "reasoning": true,
              "input": ["text"],
              "cost": { "input": 0.3, "output": 1.2, "cacheRead": 0.006, "cacheWrite": 0 },
              "contextWindow": 131072,
              "maxTokens": 32768,
              "compat": { "supportsDeveloperRole": false, "supportsStore": false, "maxTokensField": "max_tokens" }
            }
          ]
        }
      }
    }

    beside what models.json holds already

    every model
    served now, at today's prices: copy the block again when they change
    windows and prices
    pi compacts in time, and counts what a session cost
    reasoning
    sent back on later turns, as kimi- and deepseek-style models need
  3. use it

    terminal
    pi --model blackrouter/deepseek-v4.1-flash

    /model switches to any id above, under blackrouter; opening it reads models.json again

other ways

take "blackrouter" out of "providers" in models.json