Opencode Api Setup
Through OpenCode, you can connect to any LLM (Large Language Model) provider, such as OpenAI, Claude, DeepSeek, Alibaba Cloud Bailian, etc., to gain stronger AI programming capabilities.
If you are using it for the first time, it is recommended to prioritize **OpenCode Zen**. It is a set of officially curated models by OpenCode that have been tested and optimized, ready to use out of the box, and suitable for beginners.
**OpenCode Zen** also includes a large number of free large models, so you can basically use it directly without needing to top up.
* * *
### Step 1: Launch Configuration
Run directly:
opencode
> If the error **EACCES: permission denied, open ''** appears, it is a permission issue. Please execute it with administrator privileges, for example:
>
> sudo opencode
You will see the terminal interface (TUI):
!(#)
In the OpenCode terminal interface, enter:
/connect
!(#)
> Note: After using the /connect command to add a provider's API key, the credentials will be stored in ~/.local/share/opencode/auth.json.
Then select: **opencode**
!(#)
If you have API keys for other large models, you can also choose to configure them through this list.
### Step 2: Get API Key
Open the following page and log in: [https://opencode.ai/auth](https://opencode.ai/auth)
* Log in to your account
* Add billing information
* Create API Key
### Step 3: Paste API Key
Return to the terminal and paste the obtained API Key:
!(#)
Once completed, you can start using OpenCode.
We can press Esc to exit the LLM provider configuration, and then enter the /model command in the chat window to view the supported models:
!(#)
The ones with the "Free" label are the free models:
!(#)
After selection, press Esc to exit the configuration, and you can see the currently used large model:
!(#)
### Domestic Coding Plan
There are many large model vendors on the market now. Foreign ones include Anthropic, Open AI, Grok, Gemini, etc., but accessing foreign services is currently inconvenient. Domestic ones include DeepSeek, Qwen, ZLM, Minimax, etc.
The most expensive part of using Claude Code to write code is the tokens. Overseas access is inconvenient and also expensive. Domestic providers now offer monthly subscription plans. If you use it long-term, it is more cost-effective to buy a monthly subscription.
* * *
## Connect to Alibaba Cloud Bailian
OpenCode is an open-source AI programming tool that can be used with the model inference service provided by Alibaba Cloud Bailian to achieve efficient code development.
We can first use the Alibaba Cloud primary account to access the Bailian model service platform [https://bailian.console.aliyun.com/](https://bailian.console.aliyun.com/cn-beijing/?userCode=i5mn5r7m&tab=globalset#/efm/api_key), then click log in at the top right corner. After successful login, click the gear βοΈ icon at the top right corner, select API key, and then copy the API key. If you don't have one, you can also create an API key:
!(#)
!(#)
> You can directly purchase resource packages, which is more cost-effective: [https://cn.aliyun.com/benefit?from_alibabacloud=&userCode=i5mn5r7m](https://cn.aliyun.com/benefit?from_alibabacloud=&userCode=i5mn5r7m)
### Set up in OpenCode
Enter /connect in the input box and press Enter.
Enter **alibaba** in the search box of the **Connect a Provider** list to search, select Alibaba (China) and press Enter.
!(#)
Enter the API Key we applied for and press Enter:
!(#)
Then we can enter /model to view the models supported by Alibaba and select the ones we need:
!(#)
> This document is only applicable to the pay-as-you-go model. Coding Plan users please use the dedicated Base URL and API Key to connect. For details, please refer to the (#) documentation for configuration.
* * *
## Domestic API Configuration
API application addresses for domestic vendors:
| Vendor/Brand | Introduction | API Application Portal (Click to access) |
| --- | --- | --- |
| DeepSeek (Domestic high cost-performance) | Official models: deepseek-v4-flash deepseek-v4-pro deepseek-chat (will be deprecated on 2026/07/24) deepseek-reasoner (will be deprecated on 2026/07/24) | [https://platform.deepseek.com/api_keys](https://platform.deepseek.com/api_keys) |
| Volcengine Ark Coding Plan | Supports free switching among the latest models like Doubao-Seed-2.0-pro/lite/Code, Doubao-Seed-Code, MiniMax-M2.5, Kimi-K2.5, GLM-4.7, Deepseek-V3.2, or use Auto mode scheduling. | [ |
| Alibaba Cloud Bailian (Tongyi Qianwen) | Alibaba Cloud large model unified entry, supports the latest versions of models like Qwen, GLM, Kimi, MiniMax, etc. | [https://bailian.console.aliyun.com](https://bailian.console.aliyun.com/?userCode=i5mn5r7m) |
| GLM (Zhipu Qingyan) | Tsinghua-backed ChatGLM series, supports GLM-4, GLM-3-Turbo, etc. | [https://open.bigmodel.cn](https://www.bigmodel.cn/glm-coding?ic=EMWK7IPUCE) |
| MiniMax | Domestic multimodal, supports mixed calls of text, voice, and image | [https://platform.minimaxi.com](https://platform.minimaxi.com/) |
After entering the corresponding console, register/log in β complete real-name authentication β create an API Key to start calling.
### API Management Tool
When there are many platforms, configuration becomes troublesome. We can use a third-party tool CC Switch to help us easily manage the API configurations of these popular tools: [https://github.com/farion1231/cc-switch/](https://github.com/farion1231/cc-switch/), fully supporting Windows / macOS / Linux.
CC Switch is an all-around auxiliary tool for Claude Code / Codex / Gemini CLI.
CC Switch can help us easily manage the API configurations of these popular tools, just like bringing a smart organizing assistant to your development toolbox, where all tool configurations can be managed in an orderly manner.
!(#)
Download addresses for each platform's installation package: [https://github.com/farion1231/cc
YouTip