OpenCode Integration
Connect OpenCode to 200+ models via OffRail's built-in provider. No config files — select, authenticate, and code. Kimi K3, GPT-5 and Claude included.
OpenCode is an open-source AI coding agent for your terminal, IDE, or desktop. OffRail is a built-in provider in OpenCode, so setup takes under a minute — no config files or npm adapters required. You get access to 200+ models from 40+ providers, all tracked in one dashboard.
Prerequisites
- OpenCode installed — visit the OpenCode download page for your platform
- An OffRail API key
Setup
Launch OpenCode
Start OpenCode from your terminal:
opencodeIn VS Code/Cursor:
- Install the OpenCode extension from the marketplace
- Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
- Type "OpenCode" and select "Open opencode"
Open the Provider List
Once OpenCode launches, run the /providers or /connect command to open the provider selection screen.
Select OffRail
OffRail is listed as a built-in provider. Select "OffRail" from the provider list.
Enter Your API Key
OpenCode will prompt you for your API key. Enter your OffRail API key and press Enter. OpenCode will automatically save your credentials securely.
Sign up for OffRail and create an API key from your dashboard.
Start Using OpenCode
You're all set! OpenCode is now connected to OffRail. You can start asking questions and building with AI.
Why Use OffRail with OpenCode
- 200+ models — GPT-5, Claude, Gemini, Llama, and more from 40+ providers
- One API key — Stop juggling credentials for every provider
- Cost tracking — See what each coding agent costs in your dashboard
- Response caching — Repeated requests hit cache automatically
- Volume discounts — The more you use, the more you save
Adding Custom Models
The built-in provider gives you access to all standard OffRail models. If you want to add custom model aliases or configure models not yet listed in the built-in provider, you can create a config.json in your OpenCode configuration directory:
macOS/Linux: ~/.config/opencode/config.json
Windows: C:\Users\YourUsername\.config\opencode\config.json
{
"provider": {
"offrail": {
"models": {
"deepseek-v3": {
"name": "DeepSeek V3"
}
}
}
}
}Since OffRail is a built-in provider, you only need to specify what you're adding — OpenCode merges your config with the built-in provider definition, so npm, name, and baseURL don't need to be repeated.
After updating config.json, restart OpenCode to see the new models.
Pinning a Model to a Specific Provider
OpenCode's built-in model list only shows canonical model IDs (e.g. claude-sonnet-5), which OffRail routes to the best available provider automatically. If you want a model to always run on one specific provider — for example to guarantee a fixed price, a compliance boundary, or consistent behavior — use OffRail's provider/model syntax as the model ID.
Add the pinned variants you want as custom models, and they show up in OpenCode's model picker alongside the built-in list:
{
"provider": {
"offrail": {
"models": {
"anthropic/claude-sonnet-5": {
"name": "Claude Sonnet 5 (Anthropic direct)"
},
"aws-bedrock/claude-sonnet-5": {
"name": "Claude Sonnet 5 (AWS Bedrock)"
}
}
}
}
}You can also pin one as your default model, or per-agent:
{
"model": "offrail/anthropic/claude-sonnet-5"
}For providers with multiple regions, append a region suffix to pin both provider and region, e.g. aws-bedrock/claude-sonnet-5:us. See the routing docs for the full syntax, and each model's available providers on the models page.
Disabling Fallback
By default, OffRail automatically fails over to alternative providers if your chosen provider is experiencing downtime — even for provider-pinned model IDs. To make the pin strict, pass the X-No-Fallback header. Requests will then be sent only to the provider you specified, with no automatic fallback.
{
"provider": {
"offrail": {
"options": {
"headers": {
"X-No-Fallback": "true"
}
}
}
}
}Disabling fallback means requests will fail if the chosen provider is down. See the routing docs for details.
Switching Models
Select a different model directly in the OpenCode interface, or update the model field in your configuration:
{
"model": "offrail/gpt-5-mini"
}View all available models on the models page.
Troubleshooting
Connection timeout
Check that you have an active internet connection and that your API key is valid from the dashboard.
Custom models not showing up
After editing config.json, restart OpenCode completely for changes to take effect.
404 Not Found errors with custom config
If you are using a custom config.json, verify your baseURL is set to https://api.offrail.ai/v1 (note the /v1 at the end).
Configuration Tips
- Global configuration: Use
~/.config/opencode/config.jsonto apply settings across all projects - Project-specific: Place
opencode.jsonin your project root to override global settings for that project - Model selection: You can specify different models for different types of tasks using OpenCode's agent configuration
Need help? Join our Discord community for support and troubleshooting assistance.
How is this guide?