What is opencode?
opencode (by SST) is an open-source AI coding agent for the terminal. It is provider-agnostic by design: any model in the catalogue — or a custom provider you declare in opencode.json — can drive it, including any OpenAI-compatible endpoint via the AI SDK.
- A terminal-native agent that plans, edits and runs commands across your project.
- Declares custom providers in
opencode.jsonusing@ai-sdk/openai-compatible. - Reads API keys via
{env:VAR}references — secrets stay out of the config file. - Open source and model-agnostic.
Why route opencode through Tokonomix?
- One provider entry, 130+ models — pick
tokonomix-consensusor any direct slug. - Reach for consensus on the hard turns; a fast model for routine edits.
- Per-call spend caps bound an agentic session; region / origin routing for compliance.
- Keep your key in an env var via the
{env:…}reference.
Connect Tokonomix in opencode.json
Add a provider entry that uses the @ai-sdk/openai-compatible package, with the Tokonomix baseURL and an {env:…} key reference.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"tokonomix": {
"npm": "@ai-sdk/openai-compatible",
"name": "Tokonomix",
"options": {
"baseURL": "https://tokonomix.ai/api/v1",
"apiKey": "{env:TOKONOMIX_API_KEY}"
},
"models": {
"tokonomix-consensus": { "name": "Tokonomix Consensus" }
}
}
}
}Verify it works
- Export
TOKONOMIX_API_KEY, saveopencode.json, and start opencode. - Select the Tokonomix model and run a small task.
- Confirm the call and token usage in your Tokonomix dashboard.
