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

OpenCode

Use Northern Inference as your OpenCode backend

Get going in 60 seconds

Create or edit opencode.json in your project root (or ~/.config/opencode/opencode.json for a global default):

{
  "$schema": "https://opencode.ai/config.json",
  "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 (NI)" },
        "claude-sonnet-4-6-t4": { "name": "Gemini 2.5 Pro (NI, CA)" }
      }
    }
  }
}

Then add your key: run opencode auth login, scroll to Other, enter the provider id northerninference, and paste your ni_live_ key. Restart OpenCode. Both models appear in the model picker under Northern Inference.


OpenCode is a terminal-native coding agent. It supports custom OpenAI-compatible providers via the @ai-sdk/openai-compatible npm adapter -- no plugin required.

Config file

Place opencode.json in your project root for per-project config, or at ~/.config/opencode/opencode.json for a global default. The two locations can coexist; the project file takes precedence.

{
  "$schema": "https://opencode.ai/config.json",
  "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 (NI)" },
        "claude-sonnet-4-6-t4": { "name": "Gemini 2.5 Pro (NI, CA)" }
      }
    }
  }
}

Authentication

Run:

opencode auth login

Scroll to Other, enter provider id northerninference, and paste your ni_live_ key. OpenCode stores the credential in its keychain. Restart OpenCode after saving the config for the provider to appear.

Choosing model IDs

The object keys under models are sent to NI verbatim as the model field in every chat completion request. They must be exact deployed route IDs.

Copy the exact route from the live list:

curl https://northerninference.ca/v1/models | jq '.[].id'

Use the returned string case-sensitive. Display names in the model picker ("name") are cosmetic only and do not affect routing.

Key points

for custom providers. No other adapter works with NI's /v1 endpoint.

No trailing slash.

Copy them from /v1/models to be certain. A mismatched key does NOT error: it returns HTTP 200 with a message listing every route your key can call. That is a routing notice, not a model answer, so a tool that renders it will show you the list rather than fail. NI sends the same kind of notice any time it answers in place of a model. Detect one by the response id, which starts with nicmd- here and msg_nicmd_ on the Anthropic messages endpoint; every notice reports zero usage and is never billed. The model field is not a reliable test, because some notices report back the exact route id you asked for.

which. mistral-large-2402-t3 is Tier 3, Canadian-resident managed cloud; claude-sonnet-4-6-t4 is Tier 4, the provider API. No extra header or body field is needed.

Verify

After the first response, check portal → Usage to confirm the request landed on NI and shows the expected route and cost.

Cost control

OpenCode fires requests on every agentic turn. If you want a spend limit, create a dedicated key in portal → Keys → Create key with a daily spend cap and enter that key during opencode auth login.

Quirks

instance does not hot-reload the provider config.

not affect what NI receives.

expected. OpenCode passes them through unchanged to the API.

not from per-request fields. Adjust them in the portal on the key.


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