OpenCode
Overview
OpenCode is a modern command-line coding assistant built on the AI SDK. Through the @ai-sdk/openai-compatible adapter it connects to any OpenAI-compatible endpoint registered as a custom provider. Register TokenPlus as a provider to use its models in the terminal or the VS Code plugin.
Installation
- Recommended official script: curl -fsSL https://opencode.ai/install | bash
- Or npm: after ensuring Node.js 18+, run npm install -g opencode-ai
- Run opencode -v; a version number means success
Configure TokenPlus
Edit the global or project-level opencode.json, add a custom provider using @ai-sdk/openai-compatible, fill in the TokenPlus /v1 address and key, and list the available models.
// ~/.config/opencode/opencode.json (global)
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"tokenplus": {
"npm": "@ai-sdk/openai-compatible",
"name": "TokenPlus",
"options": {
"baseURL": "https://tokenplus.net/v1",
"apiKey": "sk-your-TokenPlus-key"
},
"models": {
"gpt-4o": { "name": "GPT-4o" },
"claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
"deepseek-chat": { "name": "DeepSeek Chat" }
}
}
}
}
The provider ID (tokenplus) is customizable; baseURL must include /v1; models must be listed one by one under models, with IDs from the TokenPlus console. You can also reference an environment variable for options.apiKey, e.g. {env:TP_KEY}.
Quick start (up and running in 5 minutes)
- Install opencode (script or npm -g)
- Write ~/.config/opencode/opencode.json, adding the TokenPlus provider above
- Enter your project directory and run opencode, then type /models to view and switch models
- Send a test message to verify connectivity
FAQ
- Tool calls behave abnormally? Appropriately increase the local model's num_ctx (16k-32k)
- Model not showing? Confirm it was added under models and /models has been refreshed
- Want more models? Just keep appending IDs under provider.models