Integrations
OpenCode
OpenCode in the terminal with AI Tokens: a custom provider in opencode.json, the key through /connect or an environment variable, and the limits of each model.
Last updated: 2026-10-11
Settings
Add AI Tokens as a custom provider in opencode.json, in your project or in
~/.config/opencode/:
{
"$schema": "https://opencode.ai/config.json",
"model": "aitokens/qwen3.8-27b",
"provider": {
"aitokens": {
"npm": "@ai-sdk/openai-compatible",
"name": "AI Tokens",
"options": {
"baseURL": "https://api.aitokens.ch/v1",
"apiKey": "{env:API_KEY}"
},
"models": {
"qwen3.8-27b": {
"name": "Qwen3.8 27B",
"limit": { "context": 262144, "output": 8192 }
},
"qwen3-coder-30b": {
"name": "Qwen3-Coder 30B",
"limit": { "context": 32768, "output": 8192 }
}
}
}
}
}
The key can come from two places:
{env:API_KEY}, as above, reads the environment variableAPI_KEY:export API_KEY="sk-at-…"before you start OpenCode;- or leave
apiKeyout, run/connectin OpenCode, choose Other, type the provider IDaitokensand paste the key. OpenCode keeps it in~/.local/share/opencode/auth.json.
limit.context is the context window and limit.output the most the model
may write in one answer. Write them for every model: /v1/models does not
publish them, and OpenCode has no other way to know them.
Which model
qwen3.8-27b, for its 262,144 tokens of context; qwen3-coder-30b for quick
tasks. Both returned tool calls on 11 October 2026, with and without streaming.
More in Which model.
OpenCode talks to the API through the @ai-sdk/openai-compatible package
named in npm. We tested that package with the same API on the
Vercel AI SDK page.
Limits
outputup to 8192. The API refuses amax_tokensabove 8,192 with422.- No reasoning to show: the API does not return the reasoning of
qwen3.8-27b.