Run opencode --version. If it begins with 2., follow the separate OpenCode v2 guide. The configurations are not interchangeable.
1. Create an API-key identity
In the tenant portal, create a key named for the person and client—for example Steele-OpenCode-Mac. Add project tags separately.
2. Export the key
export SAFETYROUTER_API_KEY='sr_live_...'3. Add the v1 provider
Add this provider to opencode.json. Replace the hostname and model with values allowed by your tenant.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"safetyrouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "SafetyRouter",
"options": {
"baseURL": "https://your-company.safetyrouter.io/v1",
"apiKey": "{env:SAFETYROUTER_API_KEY}",
"timeout": 900000,
"headerTimeout": 900000,
"chunkTimeout": 900000
},
"models": {
"provider/model-name": { "name": "Model via SafetyRouter" }
}
}
},
"model": "safetyrouter/provider/model-name"
}4. Start OpenCode v1
opencodeOpenCode may pause while SafetyRouter generates and inspects the full answer. Approved content is then emitted as a compatible stream.
Buffered-safety timeout
SafetyRouter intentionally waits for input review, model generation, and output review before releasing model content. Where your client exposes request, response-header, socket-read, or stream-idle timeouts, set them to at least 900000 ms or 900 seconds. Keep streaming enabled. A longer timeout preserves the safety boundary; it does not bypass inspection.
This page preserves the OpenCode 1.x configuration format. New installations should use the OpenCode v2 guide.