OpenCode¶
Connect the OpenCode CLI to Tokensor so every model call is recorded, quota-checked, and attributed to your account.
1. Save your OpenCode API key¶
In Settings → Integrations (or onboarding), save your OpenCode Zen/Go API key (from your OpenCode workspace). Tokensor stores it encrypted and injects it upstream when you call through the proxy.
2. Point the CLI at Tokensor¶
Add the opencode (Zen) and opencode-go (Go) providers to your global config ~/.config/opencode/opencode.json (or opencode.jsonc). Use your Tokensor API key (ts_...) as the apiKey:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"opencode": {
"options": {
"apiKey": "ts_your_tokensor_key",
"baseURL": "https://tokensor.dev/proxy/opencode/zen/v1"
}
},
"opencode-go": {
"options": {
"apiKey": "ts_your_tokensor_key",
"baseURL": "https://tokensor.dev/proxy/opencode/go/v1"
}
}
}
}
3. Verify¶
Run opencode models — you should see opencode/* models. Send any message and the call is recorded on your account; it appears in the dashboard and the connection status flips to connected.
Notes¶
- Only your Tokensor key lives on the CLI — the real OpenCode key stays on your Tokensor account.
- Your OpenCode account must have credits; otherwise upstream calls fail with
CreditsError(top up at your OpenCode workspace billing page).