Connect OpenCode to TokenCode for terminal-based coding tasks.
npm install -g opencode-ai
opencode -v
npm install -g @tokencode/tokencode
tokencode
Select OpenCode in the wizard. For a one-line setup, run:
npx @tokencode/tokencode od -k sk-your-api-key -m claude-sonnet-4-6
The CLI merges provider.tokencode into ~/.config/opencode/opencode.json and attempts to load the available model list.
Add this provider to ~/.config/opencode/opencode.json (on Windows: C:\Users\<username>\.config\opencode\opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"tokencode": {
"npm": "@ai-sdk/anthropic",
"name": "TokenCode",
"options": {
"baseURL": "https://tokencode.dev/v1",
"apiKey": "sk-your-api-key"
},
"models": {
"claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
"gpt-5.5": { "name": "GPT-5.5" },
"gemini-2.5-pro": { "name": "Gemini 2.5 Pro" },
"deepseek-chat": { "name": "DeepSeek Chat" }
}
}
}
}
Restart OpenCode, enter /models, and select a model under TokenCode.
If the provider is missing, validate the JSON and make sure you merged the provider object without overwriting existing fields. For 401 errors, verify the API key; for 404 errors, verify that the Base URL includes /v1.