OpenCode + TOKNADO
How to use OpenCode with TOKNADO (custom provider in opencode.json)
OpenCode is a terminal coding agent with a long list of built-in providers, plus a documented path for any OpenAI-compatible endpoint: declare the provider in opencode.json, give it a base URL, list the model IDs, and they appear in the model picker.
That makes TOKNADO a few lines of config. Here is the complete setup, including where to keep the key and the base URL mistake that causes most failures.
Start free trial Jump to setup
What you need
- OpenCode installed.
- Your TOKNADO endpoint and API key.
- At least one model ID from your TOKNADO dashboard.
Setup: OpenCode with TOKNADO
Set your API key
Keep the key in the environment instead of the config file.
export TOKNADO_API_KEY=YOUR_TOKNADO_API_KEYCreate opencode.json
Use
opencode.jsonin your project root for a per-project setup, or~/.config/opencode/opencode.jsonfor a global one. The provider ID (toknado) is your choice and becomes the first half of the model reference.{ "$schema": "https://opencode.ai/config.json", "provider": { "toknado": { "npm": "@ai-sdk/openai-compatible", "name": "TOKNADO", "options": { "baseURL": "https://toknado.up.railway.app/v1", "apiKey": "{env:TOKNADO_API_KEY}" }, "models": { "toknado/auto": { "name": "TOKNADO model" } } } }, "model": "toknado/toknado/auto" }Alternative: store the key with /connect
Instead of the env var, run
/connectinside OpenCode, scroll to Other, enter the provider ID (toknado), and paste the key.Pick the model and run
Start OpenCode and choose
toknado/toknado/autofrom the model list if it isn't already your default.opencode
Notes for real-world use
- OpenCode needs you to declare the models you want exposed. A compatible endpoint's model list doesn't always include context-window or output-limit metadata, so set limits per model if you hit truncation.
- The
@ai-sdk/openai-compatiblepackage uses the chat completions route. That matches what OpenAI-compatible gateways provide. - Agents spend requests fast. Compare your usual session volume with your plan's rolling hourly limit.
Troubleshooting OpenCode + TOKNADO
| Symptom | What to check |
|---|---|
| 404 on every request | baseURL is missing its API path. https://host will fail where https://host/v1 works; the adapter appends /chat/completions. |
| Model not in the picker | It must be listed under models with the exact ID. Restart OpenCode after editing the config. |
| Authentication error | Confirm TOKNADO_API_KEY is exported in the shell that launches OpenCode, or re-run /connect. |
| Config seems ignored | Project opencode.json takes precedence over the global one; check you edited the file OpenCode is reading. |
FAQ
Can OpenCode use any OpenAI-compatible provider?
Yes. Declare it under provider in opencode.json with npm set to @ai-sdk/openai-compatible and a baseURL.
Where does opencode.json go?
In your project root for project settings, or ~/.config/opencode/opencode.json for global settings.
How do I reference the model?
As provider-id/model-id, for example toknado/toknado/auto.
Is there a free way to test it?
TOKNADO's setup guide offers a three-day trial at up to 250 requests per rolling hour.