Claude Code base URL https://northerninference.ca Host root only. Claude Code appends /v1/messages itself. Do not add /v1 here.

Claude Code

Run Claude Code through Northern Inference using your NI API key.

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-5-t4. See them all on the Models page, or type ni-models in Claude Code once you are connected.

Set up Claude Code (Mac, Windows and Linux)

Put your settings in Claude Code's settings file. This works on every operating system, keeps working when you open a new terminal, and also applies to background sessions. Open the file in a text editor, or create it if it does not exist:

Paste this, then replace ni_live_YOUR_KEY_HERE with your key:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://northerninference.ca",
    "ANTHROPIC_AUTH_TOKEN": "ni_live_YOUR_KEY_HERE",
    "ANTHROPIC_MODEL": "claude-sonnet-5-t4",
    "ANTHROPIC_DEFAULT_MODEL": "claude-sonnet-5-t4",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5-t4",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-t4",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-sonnet-5-t4",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "claude-sonnet-5-t4",
    "CLAUDE_CODE_SUBAGENT_MODEL": "claude-sonnet-5-t4"
  }
}

claude-haiku-5-5-t4, which costs less, and claude-fable-5-1-t4 also work for the haiku and fable settings, but they may keep data, so use them there only if your key's data-retention policy is set to Allow.

Keep all seven model lines. Each one covers a different part of Claude Code, and a line you leave out makes that part's requests fail. Choosing models below explains which line covers what.

If the file already has other settings, add the "env" block next to them instead of replacing the file. Keep the key in this personal file only, never in a project's .claude/settings.json, which is shared with everyone who clones the project.

Start Claude Code with claude and type /status. You should see Anthropic base URL: https://northerninference.ca and an Auth token line naming ANTHROPIC_AUTH_TOKEN. Send any message. It appears in the portal under Usage within seconds.

Already signed in with a Claude subscription?

That is fine. Once ANTHROPIC_AUTH_TOKEN is set, Claude Code sends your Northern Inference key instead of your Claude login. The login stays saved but unused. To remove it, type /logout in Claude Code.

Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY. With ANTHROPIC_API_KEY, Claude Code asks once whether to use the key. If you answer No, it keeps sending your Claude subscription login, and Northern Inference rejects it with a 401.

Try it in one terminal first (optional)

To test before you edit the settings file, set the values in a terminal window and start Claude Code from that same window. They last only until you close it.

Mac and Linux

export ANTHROPIC_BASE_URL=https://northerninference.ca
export ANTHROPIC_AUTH_TOKEN=ni_live_YOUR_KEY_HERE
export ANTHROPIC_MODEL=claude-sonnet-5-t4
export ANTHROPIC_DEFAULT_MODEL=claude-sonnet-5-t4
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5-t4
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5-t4
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-sonnet-5-t4
export ANTHROPIC_DEFAULT_FABLE_MODEL=claude-sonnet-5-t4
export CLAUDE_CODE_SUBAGENT_MODEL=claude-sonnet-5-t4
claude

Windows PowerShell

$env:ANTHROPIC_BASE_URL = "https://northerninference.ca"
$env:ANTHROPIC_AUTH_TOKEN = "ni_live_YOUR_KEY_HERE"
$env:ANTHROPIC_MODEL = "claude-sonnet-5-t4"
$env:ANTHROPIC_DEFAULT_MODEL = "claude-sonnet-5-t4"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "claude-opus-5-5-t4"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "claude-sonnet-5-t4"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "claude-sonnet-5-t4"
$env:ANTHROPIC_DEFAULT_FABLE_MODEL = "claude-sonnet-5-t4"
$env:CLAUDE_CODE_SUBAGENT_MODEL = "claude-sonnet-5-t4"
claude

In Windows Command Prompt, use set ANTHROPIC_AUTH_TOKEN=ni_live_YOUR_KEY_HERE with no quotes around the value. If the settings file also sets a value, the settings file wins.

VS Code extension

The Claude Code extension for VS Code reads ~/.claude/settings.json too, so the settings above already cover it. Only if you do not use that file, run Preferences: Open User Settings (JSON) in VS Code and add:

"claudeCode.environmentVariables": [
  { "name": "ANTHROPIC_BASE_URL", "value": "https://northerninference.ca" },
  { "name": "ANTHROPIC_AUTH_TOKEN", "value": "ni_live_YOUR_KEY_HERE" },
  { "name": "ANTHROPIC_MODEL", "value": "claude-sonnet-5-t4" },
  { "name": "ANTHROPIC_DEFAULT_MODEL", "value": "claude-sonnet-5-t4" },
  { "name": "ANTHROPIC_DEFAULT_OPUS_MODEL", "value": "claude-opus-5-5-t4" },
  { "name": "ANTHROPIC_DEFAULT_SONNET_MODEL", "value": "claude-sonnet-5-t4" },
  { "name": "ANTHROPIC_DEFAULT_HAIKU_MODEL", "value": "claude-sonnet-5-t4" },
  { "name": "ANTHROPIC_DEFAULT_FABLE_MODEL", "value": "claude-sonnet-5-t4" },
  { "name": "CLAUDE_CODE_SUBAGENT_MODEL", "value": "claude-sonnet-5-t4" }
]

Choosing models

Claude Code asks for a model by name in more places than your main chat. The choices in /model, plan mode, subagents and background tasks each use their own setting. For every setting you leave out, Claude Code asks for one of its own Claude model names, which Northern Inference does not serve, and the request fails with a 404 such as Model 'claude-opus-5-5' is not a route this key can call. To you, this looks like errors now and then between requests that work, or like plan mode, subagents or background tasks that do not work. Set every variable in this list.

The examples above use a Claude model for each choice. A model that is not Claude works too, for example DeepSeek-V4-Flash-t4: set every variable to it.

To switch models during a session, type /model claude-opus-5-5-t4, or start with claude --model claude-opus-5-5-t4. Any name from the Models page works.

Thinking level

Claude Code calls this effort. Set it at launch, or type /effort in a session to change it:

claude --effort low
claude --effort medium
claude --effort high
claude --effort max

The levels a model accepts depend on the model. Claude Sonnet 4.6 and Opus 4.6 accept low, medium, high and max. On a non-Claude model, Northern Inference turns the effort into low, medium or high for you.

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 ask from inside Claude Code with these commands. They answer straight away, do not call a model and are not billed.

A mapping applies to your whole account. You can also review or delete mappings in the portal under Models, in Model name mappings.

Switching back

To stop using Northern Inference, remove the lines you added from the "env" block in your settings file, or close the terminal where you set them. Then quit and restart every Claude Code session that is still open. A running session keeps the settings it started with, so it keeps sending requests to Northern Inference until you restart it.

Undo these too, if you did them:

Troubleshooting

What you seeWhat to do
/status shows a Login method line with your Claude account, and no Auth token line Claude Code did not read your key. Check the settings file path and that the JSON is valid (quotes, commas, braces), then restart Claude Code.
401 from Northern Inference The key is wrong, or Claude Code is sending your Claude subscription login. Put your ni_live_ key in ANTHROPIC_AUTH_TOKEN and check /status. If you set ANTHROPIC_API_KEY before and answered No, remove it, or turn on Use custom API key in /config.
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 'claude-opus-5-5' is not a route this key can call. while other requests work One of Claude Code's model variables is not set. The part of Claude Code that uses it, such as plan mode, a subagent, a background task or the Default choice in /model, still asks for a Claude model name. Set every variable listed in Choosing models, restart Claude Code, and check that claude --version shows 2.1.236 or later.
404 Model 'X' is not a route this key can call. Use a model name from the Models page, or type ni-models. See If a model name is not recognized above.
Requests do not show up in Usage Claude Code is not pointed at Northern Inference. /status should show Anthropic base URL: https://northerninference.ca. Use the host only, with no /v1 at the end.

Anything not working as expected? Write to support at northerninference dot ca. Include the X-NI-Request-ID if one was returned.

↑