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-11-03
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/mistral-medium-3.5-128b",
"provider": {
"aitokens": {
"npm": "@ai-sdk/openai-compatible",
"name": "AI Tokens",
"options": {
"baseURL": "https://api.aitokens.ch/v1",
"apiKey": "{env:API_KEY}"
},
"models": {
"mistral-medium-3.5-128b": {
"name": "Mistral Medium 3.5",
"limit": { "context": 262144, "output": 32768 }
}
}
}
}
}
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 you add, with the context
window from Which model: OpenCode does not
read them from /v1/models.
Which model
mistral-medium-3.5-128b, for its 262,144 tokens of
context.
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 32768. The API refuses amax_tokensabove 32,768 with422.- No reasoning to show: the API does not return a model's reasoning.