OpenCode: OpenCode API Setup and DeepSeek
Last updated: 2026-08-31
OpenCode doesn't include AI models—you need to configure API keys to connect to LLM services.
1. What You Will Learn
- OpenCode Zen free mode
- API Key configuration flow
- DeepSeek integration
- Regional API configuration
- CC Switch management tool
2. OpenCode Zen (Recommended for Beginners)
OpenCode Zen is a curated set of models, tested and optimized for immediate use. Zen includes many free models—no payment required.
(1) Configuration Steps
Run in terminal:
opencode
In the OpenCode TUI, enter:
/connect
Select opencode, then follow prompts to get an API Key.
(2) Get API Key
Visit https://opencode.ai/auth, log in and create an API Key.
(3) Paste API Key
Return to the terminal and paste the API Key.
(4) View Available Models
/model
Models marked Free can be used at no cost.
3. Connecting to DeepSeek
DeepSeek is a cost-effective LLM recommended for users in regions with limited access to international services.
(1) Get API Key
Visit https://platform.deepseek.com/api_keys, register and create an API Key.
DeepSeek models:
| Model | Description |
|---|---|
| deepseek-v4-flash | Fast version |
| deepseek-v4-pro | Professional version |
(2) Configure in OpenCode
In TUI enter /connect, select DeepSeek, paste API Key.
(3) Select Model
/model
Choose a DeepSeek model from the list.
4. Connecting to Alibaba Bailian
(1) Get API Key
Visit the Alibaba Cloud Bailian console at https://bailian.console.aliyun.com/, click the gear icon → API Key → copy or create.
(2) Configure in OpenCode
/connect
Search for alibaba, select Alibaba (China), paste API Key.
(3) Select Model
/model
Choose from Alibaba's supported models.
5. Regional API Overview
| Provider | Models | API URL |
|---|---|---|
| DeepSeek | deepseek-v4-flash / v4-pro | https://platform.deepseek.com/api_keys |
| Volcano Engine Coding Plan | Doubao / MiniMax / Kimi / GLM / DeepSeek | https://www.volcengine.com/activity/codingplan |
| Alibaba Bailian | Qwen / GLM / Kimi / MiniMax | https://bailian.console.aliyun.com |
| GLM (Zhipu) | GLM-4 series | https://open.bigmodel.cn |
| MiniMax | Multimodal models | https://platform.minimaxi.com |
6. CC Switch Management Tool
CC Switch is an API configuration manager for Claude Code / Codex / OpenCode.
- GitHub: https://github.com/farion1231/cc-switch/
- Supports Windows / macOS / Linux
Configuration steps:
- Open CC Switch, select OpenCode icon
- Click the add button
- Select a provider (e.g., DeepSeek)
- Enter API Key
- Set model name
Test after configuration:
opencode run Explain the principle of closures in JavaScript
❓ FAQ
~/.local/share/opencode/auth.json. Not uploaded to cloud. Still recommended to rotate keys periodically.📖 Summary
- Beginners should try OpenCode Zen with free models
- DeepSeek is cost-effective for users in regions with limited international access
- Alibaba Bailian supports multiple models for flexible switching
- CC Switch can manage multiple API configurations
- API Keys are stored locally—keep them secure
📝 Exercises
-
Basic: Configure OpenCode Zen or DeepSeek API Key, start OpenCode successfully.
-
Intermediate: Configure two different API providers simultaneously and switch between them.
-
Advanced: Use CC Switch to manage your API configurations and complete a non-interactive call from the command line.