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 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:

BASH
opencode

In the OpenCode TUI, enter:

TEXT 📖 Display only
/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

TEXT 📖 Display only
/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

TEXT 📖 Display only
/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

TEXT 📖 Display only
/connect

Search for alibaba, select Alibaba (China), paste API Key.

(3) Select Model

TEXT 📖 Display only
/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.

Configuration steps:

  1. Open CC Switch, select OpenCode icon
  2. Click the add button
  3. Select a provider (e.g., DeepSeek)
  4. Enter API Key
  5. Set model name

Test after configuration:

BASH
opencode run Explain the principle of closures in JavaScript

❓ FAQ

Q Are OpenCode Zen free models sufficient?
A For learning and lightweight development, yes. For stronger code generation, consider paid models like DeepSeek-v4-pro or Claude Sonnet.
Q Can multiple API Keys be configured simultaneously?
A Yes. Add multiple providers via /connect, then switch with /model.
Q Alice uses DeepSeek, Bob uses Alibaba Bailian—who gets better results?
A Depends on the task. DeepSeek excels at code generation; Alibaba Bailian offers more model choices. Both should try and choose what suits their workflow.
Q Where are API Keys stored?
A Locally in ~/.local/share/opencode/auth.json. Not uploaded to cloud. Still recommended to rotate keys periodically.

📖 Summary


📝 Exercises

  1. Basic: Configure OpenCode Zen or DeepSeek API Key, start OpenCode successfully.

  2. Intermediate: Configure two different API providers simultaneously and switch between them.

  3. Advanced: Use CC Switch to manage your API configurations and complete a non-interactive call from the command line.

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏