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": {
        "bedrock/global.anthropic.claude-sonnet-4-6-global": { "name": "Claude Sonnet 4.6 (NI)" },
        "vertex_ai/gemini-2.5-pro-ca": { "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": {
        "bedrock/global.anthropic.claude-sonnet-4-6-global": { "name": "Claude Sonnet 4.6 (NI)" },
        "vertex_ai/gemini-2.5-pro-ca": { "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 returns 400 model_not_found.

routes through Canadian-resident Vertex AI (Tier 3). 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.