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

pi (pi-coding-agent)

Use Northern Inference with @mariozechner/pi-coding-agent

Get going in 30 seconds

npm install -g @mariozechner/pi-coding-agent

Create ~/.pi/agent/models.json:

{
  "providers": {
    "northerninference": {
      "baseUrl": "https://northerninference.ca/v1",
      "api": "openai-completions",
      "apiKey": "ni_live_REPLACE_WITH_YOUR_KEY",
      "models": [
        { "id": "vertex_ai/gemini-2.5-pro-ca" }
      ]
    }
  }
}
pi

In pi, use /model to pick your NI model, then type your prompt.


pi (@mariozechner/pi-coding-agent, source badlogic/pi-mono) is an MIT- licensed terminal coding harness. It speaks OpenAI Chat Completions natively, so NI works as a custom provider with no patching.

Install

npm install -g @mariozechner/pi-coding-agent

The binary is named pi.

Config file

~/.pi/agent/models.json (this exact path; pi reads it on startup AND on every /model switch):

{
  "providers": {
    "northerninference": {
      "baseUrl": "https://northerninference.ca/v1",
      "api": "openai-completions",
      "apiKey": "ni_live_REPLACE_WITH_YOUR_KEY",
      "models": [
        { "id": "azure/DeepSeek-V4-Pro-global" },
        { "id": "azure/DeepSeek-V4-Flash-global" },
        { "id": "vertex_ai/gemini-2.5-pro-ca" }
      ]
    }
  }
}

Three rules that catch most setup mistakes:

  1. **baseUrl is https://northerninference.ca/v1** - host root with

/v1, no trailing slash, no /chat/completions suffix. pi's OpenAI client appends /chat/completions itself.

  1. **apiKey must start with ni_live_** - that's our key prefix.

Don't paste with quotes around it from somewhere else; raw string.

  1. **models[].id is the routing key, not a friendly name.** Use exact

strings from https://northerninference.ca/v1/models. Mixing provider prefix is required (azure/..., bedrock/...).

Running

pi

Then in pi:

the northerninference provider section.

Route selection

NI routes to the upstream based on the model route key. Copy exact model IDs from /models or /api/billing/models into ~/.pi/agent/models.json. Use API key allowed route tiers to control which routes the key may call:

  1. NI portal → Keys → edit your key → set allowed route tiers.
  2. Save. Calls to disallowed model routes return 400.

To use a different route, change the exact model route key in your config.

Troubleshooting

"Invalid API key format" or "401 Unauthorized" with no further detail

Run pi with verbose HTTP logging (if the env var works for pi's transport):

NODE_DEBUG=http,https pi

Confirm the request includes Authorization: Bearer ni_live_.... If the header is missing or empty, pi isn't picking up apiKey from the config. Common causes:

camelCase per pi's schema).

python -m json.tool < ~/.pi/agent/models.json to check.

picked one of those instead. Unset them or move the NI provider above the conflicting one.

"Route not allowed" or "ambiguous model route" 400 error

Your key is not allowed to use that model route, or the model ID is an unsuffixed base with multiple deployed routes. See Route selection above.

"Model not found" 400 error

Your models[].id doesn't match a deployed model. Visit https://northerninference.ca/models to see the current routing keys.

Rotating your key

If you've ever pasted your ni_live_... key into a chat, IRC, screenshot, or pair-debug session, treat it as compromised. NI portal → Keys → revoke → create a fresh one → update ~/.pi/agent/models.json.


Source: tests/user_run_tests/integrations/pi.md. Spot a problem? Let us know.