OpenCode
[OpenCode](https://opencode.ai) 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.
## Configuration
```json title="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)" }
}
}
}
}
```
:::caution
`baseURL` ends with `/v1`, not `/v1/chat/completions`: the client adds the path itself.
:::
## API key
```bash frame="terminal"
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`.
## Choosing a model
The `/models` command in OpenCode opens the model list. Pick a model from the `Waibee` provider, for example `waibee/auto` for [Autorouting](/router/autorouting/).
:::caution[Models are added by hand]
OpenCode does not fetch the catalog automatically: only the models listed in the `models` block are available. Add each model you need by hand, always with an ID in the `<provider>/<model>` format.
:::
To avoid adding models one at a time, you can build `models` from the catalog automatically:
```bash frame="terminal"
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`.
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.
Configuration
Section titled “Configuration”{ "$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)" } } } }}API key
Section titled “API key”export WAIBEE_API_KEY="sk_live_..."opencodeThe {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.
Choosing a model
Section titled “Choosing a model”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:
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.