Tool setup
OpenCode
Add the gateway as an OpenAI-compatible provider in opencode.json.
OpenCode is an open-source terminal coding agent. It reads providers from a JSON config, so you add the gateway as one more OpenAI-compatible provider.
What you get
- OpenCode running against every model on the gateway, on your project's sponsor budget.
- Model switching from inside OpenCode with
/models.
Prerequisites
-
Your project access key and base URL from your project control panel —
YOUR_PROJECT_KEYandhttps://v1.opentokenmarket.devbelow. -
OpenCode installed:
npm install -g opencode-ai
Configure
Add a provider block to opencode.json (project root) or ~/.config/opencode/opencode.json
(global):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"opentokenmarket": {
"npm": "@ai-sdk/openai-compatible",
"name": "OpenTokenMarket",
"options": {
"baseURL": "https://v1.opentokenmarket.dev",
"apiKey": "YOUR_PROJECT_KEY"
},
"models": {
"gpt-4o": { "name": "GPT-4o" },
"claude-sonnet-4-6": { "name": "Claude Sonnet" }
}
}
}
}
baseURLincludes/v1— OpenCode's OpenAI-compatible adapter expects it.- List one entry under
modelsfor each model you want in the picker. Use exact names from the model catalog;nameis just the display label. - Prefer an env var over a key in the file? Drop
options.apiKeyand exportOPENAI_API_KEY=YOUR_PROJECT_KEYinstead.
Run
opencode
Then /models and pick one of your OpenTokenMarket entries.
Verify
curl https://v1.opentokenmarket.dev/chat/completions \
-H "Authorization: Bearer YOUR_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"ping"}]}'
Troubleshooting
- Provider missing from
/models—opencode.jsonisn't valid JSON, or it's in a directory OpenCode didn't load. Run OpenCode from the project root. 404on requests —baseURLis missing the trailing/v1.- Reasoning models error out — some models reject the extra parameters OpenCode sends with reasoning enabled. Try a non-reasoning model, or ask the gateway operator to drop the unsupported params for that model.
budget has been exceeded— ask your sponsor to top up the project.
Which model names to use
The keys under models must match the Model name column in the
model catalog.