Before you start
- Create an API key. In the portal, open Keys and click Create Key. Your key starts with
ni_live_. - 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.
- 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 see | What to do |
|---|---|
| Northern Inference is missing from the model picker | Check that opencode.json is valid JSON and in the folder you start OpenCode from, then restart OpenCode. |
| 401 | The 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.