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, or typeni-modelsin 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.
ni-modelslists the models your key can call, numbered.ni-map-model 3sends the model name in your config to model 3 from that list.ni-map-model <model-name>does the same with an exact name.ni-statusshows your mappings, andni-unmapremoves the one for your current model.ni-helplists every command.
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 see | What 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.