OpenCode supports custom OpenAI-compatible providers. Its current Providers guide recommends storing the credential with /connect, then declaring the provider and models in opencode.json.
Completion path: create a key → store it with /connect → configure the
provider → send a short test request → confirm it in Usage Logs.
Install OpenCode
Official installer:
curl -fsSL https://opencode.ai/install | bash
Or use npm or Homebrew:
npm install -g opencode-ai
brew install anomalyco/tap/opencode
Store the credential
Start opencode and run:
/connect
Choose Other, enter nbility as the provider ID, and paste a key created on Token Management. The ID must match the configuration key below.
Configure the provider
Create opencode.json in the project root or at ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"nbility": {
"npm": "@ai-sdk/openai-compatible",
"name": "Nbility",
"options": {
"baseURL": "https://api.nbility.ai/v1"
},
"models": {
"gpt-5.4": {
"name": "GPT-5.4"
},
"claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6"
}
}
}
}
}
@ai-sdk/openai-compatible uses /v1/chat/completions. If a model explicitly requires /v1/responses, follow OpenCode's guidance and use @ai-sdk/openai; do not mix the two protocols.
Use Models as the source of truth and add or remove models entries as needed.
Use and troubleshoot
Restart OpenCode, run /models, and select nbility/<model-id>.
- Provider missing: ensure the
/connectID and config key are bothnbility. 401: runopencode auth list, then use/connectto replace the credential.404: ensurebaseURLincludes/v1and the npm adapter matches the endpoint protocol.- Tool calls fail: use a model with native tool-calling support. Chat API compatibility alone does not guarantee agent tools.
As an alternative to OpenCode credential storage, set options.apiKey to {env:NBILITY_API_KEY}. Never hardcode the real key.