Skip to content
docs

OpenCode

OpenCode connects any OpenAI-compatible endpoint as a provider. Waibee Router serves POST /v1/chat/completions, so you only need to define the provider in opencode.json, either in the project root or in ~/.config/opencode/opencode.json to make it available in every project.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"waibee": {
"npm": "@ai-sdk/openai-compatible",
"name": "Waibee",
"options": {
"baseURL": "https://api.waibee.com/v1",
"apiKey": "{env:WAIBEE_API_KEY}"
},
"models": {
"anthropic/claude-sonnet-4.6": { "name": "Claude Sonnet 4.6" },
"openai/gpt-5.2": { "name": "GPT-5.2" },
"waibee/auto": { "name": "Auto (Waibee routing)" }
}
}
}
}
Terminal window
export WAIBEE_API_KEY="sk_live_..."
opencode

The {env:WAIBEE_API_KEY} syntax substitutes the key from the environment. If the variable is not set, OpenCode substitutes an empty string, and the router responds with 401.

The /models command in OpenCode opens the model list. Pick a model from the Waibee provider, for example waibee/auto for Autorouting.

To avoid adding models one at a time, you can build models from the catalog automatically:

Terminal window
curl -s https://api.waibee.com/v1/models \
-H "Authorization: Bearer $WAIBEE_API_KEY" \
| jq '[.data[] | {key: .id, value: {name: .name}}] | from_entries'

Paste the result into the models field of your provider in opencode.json.