OpenCode
OpenCode is an open-source AI coding agent for the terminal, desktop, and IDE. It supports custom OpenAI-compatible providers through its opencode.json config file.
Quick setup
Paste your API key below, select your models, then copy the generated config into your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"modelbridge": {
"npm": "@ai-sdk/openai-compatible",
"name": "ModelBridge",
"options": {
"baseURL": "https://api.modelbridge.dev/v1",
"apiKey": "sk_your_api_key_here"
},
"models": {
"claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6",
"limit": {
"context": 200000,
"output": 16384,
"modalities": [
"text",
"image"
]
},
"variants": {
"max": {
"reasoningEffort": "max"
},
"high": {
"reasoningEffort": "high"
},
"medium": {
"reasoningEffort": "medium"
},
"low": {
"reasoningEffort": "low"
},
"none": {
"reasoningEffort": "none"
}
}
}
}
}
},
"model": "modelbridge/claude-sonnet-4-6"
}Place the config file at ~/.config/opencode/opencode.json (global) or opencode.json in your project root (per-project).
Setup steps
- Install OpenCode if you haven't already
- Create or edit your
opencode.jsonconfig file - Paste the generated config above
- Run
opencodeand select your ModelBridge model with/model
Reasoning effort variants
The generated config includes variants for each model, letting you switch between reasoning effort levels without duplicating models. Use the variant_cycle keybind in OpenCode to quickly switch between them.
All models get these variants:
- high -- High reasoning effort (best for complex tasks)
- medium -- Balanced reasoning (good default)
- low -- Minimal reasoning (fastest, cheapest)
- none -- No reasoning at all
Additionally:
- Claude models get a max variant for maximum reasoning budget
- GPT models get an xhigh variant for extra-high reasoning effort
Image support
Models that support vision (Claude, GPT-5.x) are configured with modalities: ["text", "image"] so OpenCode can send images to them. This enables features like screenshot analysis and image-based prompts.
Configuration details
npm-- Uses@ai-sdk/openai-compatiblefor the OpenAI-compatible protocoloptions.baseURL-- Set tohttps://api.modelbridge.dev/v1options.apiKey-- Your ModelBridge API keymodels-- Each model includes a displayname,limit(context/output/modalities), andvariantsmodel-- The default model inprovider/model-idformat (e.g.modelbridge/claude-sonnet-4-6)
Switching models
In OpenCode, use the /model command to switch between configured models. All ModelBridge models appear under the "ModelBridge" provider. Use the variant_cycle keybind to switch reasoning effort without changing models.