API endpoint https://northerninference.ca/v1 OpenAI-style clients use /v1. Anthropic SDK / Claude Code use the host root instead.

Codex

Run Codex 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-4-6-t4. See them all on the Models page, or type ni-models in Codex once you are connected.

Set up Codex

1. Edit your Codex config file. Open ~/.codex/config.toml in a text editor, or create it if it does not exist. On Windows, ~ is your user folder, so the file is C:\Users\you\.codex\config.toml. Add these lines at the top of the file:

model_provider = "northerninference"
model = "claude-sonnet-4-6-t4"

[model_providers.northerninference]
name = "Northern Inference"
base_url = "https://northerninference.ca/v1"
env_key = "NI_API_KEY"
wire_api = "responses"

2. Give Codex your key. Codex reads it from the NI_API_KEY environment variable.

Mac and Linux

export NI_API_KEY=ni_live_YOUR_KEY_HERE
codex

To keep the key for new terminals, add the export line to ~/.zshrc or ~/.bashrc.

Windows PowerShell

setx NI_API_KEY "ni_live_YOUR_KEY_HERE"

setx saves the key for every new terminal. Close this window, open a new one and run codex. To try it in the current window only, use $env:NI_API_KEY = "ni_live_YOUR_KEY_HERE" instead.

3. Check it works. Send any message in Codex. It appears in the portal under Usage within seconds.

Put these lines in your personal ~/.codex/config.toml, not in a project's own .codex/config.toml.

Keep your usual Codex setup as well (optional)

If you also use Codex with your ChatGPT account, keep Northern Inference in its own profile instead. Put the same lines in ~/.codex/northerninference.config.toml rather than in config.toml, then start Codex with:

codex --profile northerninference

Plain codex keeps using your normal setup.

Choosing a model

Change model in the config file, or pick a model for one run:

codex --model claude-opus-4-6-t4

Any name from the Models page works. Codex sends requests in the Responses format, which is why the config has wire_api = "responses".

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 Codex. Type one of these commands as the whole message. 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.

Troubleshooting

What you seeWhat to do
Codex says the NI_API_KEY variable is missing The key is not set in this terminal. On Windows, open a new terminal after setx.
401 from Northern Inference The key is wrong or was revoked. Copy it again from the portal under Keys, without quotes or spaces.
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 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 Codex is not using the Northern Inference provider. Check that model_provider = "northerninference" is at the top of ~/.codex/config.toml, above any [section].

If a request returns an NI error, include the X-NI-Request-ID when contacting support.

↑