Integration guide
OpenCode
OpenCode loads providers from opencode.json. Register Relay through @ai-sdk/openai-compatible and pick a relay/ model — billing stays per token on your Relay balance.
Setup
- 1
Create a Relay API key in the console.
- 2
Save the provider block to ~/.config/opencode/opencode.json (or a project-level opencode.json) — it registers relay on the OpenAI-compatible endpoint.
- 3
Replace YOUR_MODEL_ID with a catalog model, then launch opencode and select relay/YOUR_MODEL_ID.
Configuration
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"relay": {
"npm": "@ai-sdk/openai-compatible",
"name": "Relay",
"options": {
"baseURL": "https://proxystacks.com/v1",
"apiKey": "sk-relay-your-key"
},
"models": {
"YOUR_MODEL_ID": {
"name": "YOUR_MODEL_ID"
}
}
}
},
"model": "relay/YOUR_MODEL_ID"
}Save to ~/.config/opencode/opencode.json (or a project-level opencode.json), then pick model relay/YOUR_MODEL_ID.