Skip to content
StatusGet API key

OpenCode

OpenCode reaches OpenAI-compatible APIs through the @ai-sdk/openai-compatible package. Add TOKEN as a provider in opencode.json (in your project, or in ~/.config/opencode/ for every project):

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"token": {
"npm": "@ai-sdk/openai-compatible",
"name": "TOKEN",
"options": {
"baseURL": "https://api.thetoken.dev/v1",
"apiKey": "{env:TOKEN_API_KEY}"
},
"models": {
"moonshotai/kimi-k3": { "name": "Kimi K3" },
"zai-org/glm-5.3": { "name": "GLM-5.3" },
"zai-org/glm-5.3-flash": { "name": "GLM-5.3 Flash" },
"deepseek/deepseek-v4-pro": { "name": "DeepSeek V4 Pro" }
}
}
}
}
  • options.apiKey reads the key from the TOKEN_API_KEY environment variable. Instead, you can leave apiKey out, run /connect in OpenCode, choose Other, enter the provider ID token and paste the key; OpenCode then stores it in its own credentials file.
  • The keys under models are TOKEN model IDs; name is only the label OpenCode shows. Add any model from the models page that has tool calling.
  • Pick the model with /models in OpenCode; it is listed as token/<model ID>.

Choosing a model: OpenCode’s agent calls tools on most steps; use moonshotai/kimi-k3, zai-org/glm-5.3 or deepseek/deepseek-v4-pro, and a cheaper model such as zai-org/glm-5.3-flash for small tasks.