API endpoint https://northerninference.ca/v1 Use this as the base URL in every integration.

OpenCode

Use Northern Inference as your OpenCode backend with exact sovereign Canadian routes and per-request custody records for government and regulated teams.

Northern Inference is a sovereign Canadian AI API for government, defence, health and regulated teams, including organizations under the Controlled Goods Program. Every route carries PIPEDA-aligned Canadian data residency, an exact path to the latest frontier and open-weight models, and a per-request chain-of-custody record.

Before you start

  1. Create an API key. In the portal, open Keys and click Create Key. Your key starts with ni_live_.
  2. Add credit. New accounts start with a balance of $0, and every request is refused until you add credit. Open Billing and click Buy credits.
  3. Pick a model. Northern Inference model names end in a tier tag, for example claude-sonnet-4-6-t4. See them all on the Models page.

Set up OpenCode

1. Add Northern Inference to your OpenCode config. Create a file named opencode.json in your project folder and paste this. This works on every operating system. To use it for all projects, put it in ~/.config/opencode/opencode.json on Mac and Linux, or C:\Users\you\.config\opencode\opencode.json on Windows, instead.

{
  "$schema": "https://opencode.ai/config.json",
  "model": "northerninference/claude-sonnet-4-6-t4",
  "small_model": "northerninference/claude-haiku-4-5-20251001-t4",
  "provider": {
    "northerninference": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Northern Inference",
      "options": { "baseURL": "https://northerninference.ca/v1" },
      "models": {
        "claude-sonnet-4-6-t4": { "name": "Claude Sonnet 4.6" },
        "claude-haiku-4-5-20251001-t4": { "name": "Claude Haiku 4.5" }
      }
    }
  }
}

model is the model OpenCode starts with. small_model is the model it uses for small background jobs such as naming your sessions. Setting both keeps every request on Northern Inference.

2. Add your key. Run opencode auth login, choose Other, enter the provider id northerninference and paste your ni_live_ key. OpenCode saves it for you, so you do not need to set any environment variable.

3. Restart OpenCode and send a message. It appears in the portal under Usage within a few seconds.

Adding more models

Each name under models is sent to Northern Inference exactly as written, so it must match a name on the Models page, including its case. The "name" next to it is only the label OpenCode shows you. Names ending in -t3 run in Canada, for example mistral-large-2402-t3.

OpenCode reads opencode.json when it starts, so restart it after a change.

If a model name is not recognized

Northern Inference answers with HTTP 404 and Model 'X' is not a route this key can call. It never swaps in a different model. Use a name from the Models page, or type ni-models as a chat message to list the models your key can call. These ni- commands answer straight away and are not billed.

Troubleshooting

What you seeWhat to do
Northern Inference is missing from the model pickerCheck that opencode.json is valid JSON and in the folder you start OpenCode from, then restart OpenCode.
401The key is wrong or missing. Run opencode auth login again for northerninference.
402 Insufficient credits. Add credits in the portal under Billing (https://northerninference.ca/portal/?page=billing) to continue.Add credit in the portal under Billing.
404 Model 'X' is not a route this key can call.Use a name from the Models page, or type ni-models.

Spend limits

OpenCode can make many requests in one task. To cap spending, create a separate key in the portal under Keys, set a daily spend limit when you create it, and use that key in OpenCode.


Spot a problem? Write to support at northerninference dot ca.

↑