OpenCode
One provider block in opencode.json. Any model on the list.
Where the settings are
opencode.json in the project root, or ~/.config/opencode/opencode.json for every project. OpenCode merges the two; the project file wins on keys that clash.
Keys saved with /connect live in ~/.local/share/opencode/auth.json.
The provider block
OpenCode only takes an OpenAI-compatible base URL for a custom provider, so use the @ai-sdk/openai-compatible package. Every id under models shows up in the /models picker. Any id on the Models page works, Claude included.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"uplinkswitch": {
"npm": "@ai-sdk/openai-compatible",
"name": "UplinkSwitch",
"options": {
"baseURL": "https://api.uplinkswitch.com/v1",
"apiKey": "{env:UPLINKSWITCH_API_KEY}"
},
"models": {
"claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" },
"claude-opus-5-5": { "name": "Claude Opus 5.5" },
"gpt-6.1-sol": { "name": "GPT-6.1 Sol" },
"gemini-3.1-pro-preview": { "name": "Gemini 3.1 Pro" },
"deepseek-v4-pro-0813": { "name": "DeepSeek V4 Pro" },
"kimi-k3": { "name": "Kimi K3" }
}
}
},
"model": "uplinkswitch/claude-sonnet-5-5",
"small_model": "uplinkswitch/claude-haiku-5-5"
}model and small_model take provider/model. Each model entry can also carry limit.context and limit.output (tokens in, tokens out) if you want OpenCode to budget context for it.
The key
{env:UPLINKSWITCH_API_KEY} reads the variable at start. An unset variable becomes an empty string, so export it before you run OpenCode:
export UPLINKSWITCH_API_KEY="sk-uplink-live-..."
opencodeOr skip options.apiKey and store the key with /connect: scroll to Other, enter the provider id uplinkswitch, paste the key. The id must match the key you used under provider.
Check it
Confirm the key before you open the TUI:
curl https://api.uplinkswitch.com/v1/models -H "Authorization: Bearer $UPLINKSWITCH_API_KEY"Then run opencode and /models. UplinkSwitch and the ids you listed appear in the picker. opencode auth list shows the stored credential if you used /connect.
Good to know
@ai-sdk/openai-compatiblecalls/v1/chat/completions. OpenCode reserves@ai-sdk/openaifor/v1/responses; use the compatible package here.- Only the ids you list are offered. Add a new one to
modelswhen the Models page gains it. small_modelhandles light work such as titles. Leave it out and OpenCode picks a cheaper model from the provider if it finds one, otherwise the main model.blacklistandwhiteliston the provider hide or keep ids in/models, by the same ids.