OpenCode
OpenCode is a terminal-based AI coding assistant. You can connect it to Alibaba Cloud Model Studio using a pay-as-you-go plan, Coding Plan, Token Plan Personal Edition, or Token Plan Team Edition.
Install OpenCode
-
Install or update Node.js to version 18.0 or later.
-
In your terminal, run the following command to install OpenCode:
npm install -g opencode-aiVerify the installation by running the following command. If the command returns a version number, the installation is successful.
opencode -v
Configure access credentials
Open the following configuration file in a text editor. If the directory or file does not exist, create it.
-
macOS / Linux:
~/.config/opencode/opencode.json -
Windows:
C:\Users\<Your-Username>\.config\opencode\opencode.json
Choose a billing method and add the corresponding configuration to the file:
-
Token Plan Personal Edition: A personal subscription that deducts personal Credits based on token consumption.
-
Token Plan Team Edition: A seat-based subscription where token consumption is deducted from Credits.
-
Coding Plan: A fixed-fee monthly subscription billed by the number of model invocations.
-
Pay-as-you-go: A post-paid method based on actual usage.
Token Plan Personal Edition
You must have an active Token Plan Personal Edition subscription. You can purchase one on the Token Plan Personal Edition page.
Replace YOUR_API_KEY with your dedicated Token Plan Personal Edition API Key. For a list of available models, see supported models.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"bailian-token-plan-personal": {
"npm": "@ai-sdk/anthropic",
"name": "Alibaba Cloud Model Studio",
"options": {
"baseURL": "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"qwen3.8-max": {
"name": "Qwen3.8 Max",
"reasoning": true,
"limit": {
"context": 983616,
"output": 131072
},
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"effort": "xhigh"
}
},
"qwen3.7-max": {
"name": "Qwen3.7 Max",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"qwen3.7-plus": {
"name": "Qwen3.7 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"qwen3.6-flash": {
"name": "Qwen3.6 Flash",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"glm-5.2": {
"name": "GLM-5.2",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"deepseek-v4-pro": {
"name": "DeepSeek V4 Pro"
},
"deepseek-v4-pro-0813": {
"name": "DeepSeek V4 Pro 0813"
},
"deepseek-v4-flash-0731": {
"name": "DeepSeek V4 Flash 0731"
}
}
}
}
}
Token Plan Team Edition
You must have an active Token Plan Team Edition subscription. You can purchase one on the Token Plan Team Edition page.
Replace YOUR_API_KEY with your dedicated Token Plan Team Edition API key. For a list of available models, see supported models.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"bailian-token-plan": {
"npm": "@ai-sdk/anthropic",
"name": "Alibaba Cloud Model Studio",
"options": {
"baseURL": "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"qwen3.8-max": {
"name": "Qwen3.8 Max",
"reasoning": true,
"limit": {
"context": 983616,
"output": 131072
},
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"effort": "xhigh"
}
},
"qwen3.7-max": {
"name": "Qwen3.7 Max",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"qwen3.7-plus": {
"name": "Qwen3.7 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"qwen3.6-plus": {
"name": "Qwen3.6 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"qwen3.6-flash": {
"name": "Qwen3.6 Flash",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"deepseek-v4-pro": {
"name": "DeepSeek V4 Pro"
},
"deepseek-v4-pro-0813": {
"name": "DeepSeek V4 Pro 0813"
},
"deepseek-v4-flash": {
"name": "DeepSeek V4 Flash"
},
"deepseek-v4-flash-0731": {
"name": "DeepSeek V4 Flash 0731"
},
"deepseek-v3.2": {
"name": "DeepSeek V3.2"
},
"kimi-k2.7-code": {
"name": "Kimi K2.7 Code",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"kimi-k2.6": {
"name": "Kimi K2.6",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"kimi-k2.5": {
"name": "Kimi K2.5",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"glm-5.2": {
"name": "GLM-5.2",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"glm-5.1": {
"name": "GLM-5.1",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"glm-5": {
"name": "GLM-5",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"MiniMax-M2.5": {
"name": "MiniMax M2.5"
}
}
}
}
}
Coding Plan
Replace YOUR_API_KEY with your dedicated Coding Plan API key. For a list of available models, see supported models.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"bailian-coding-plan": {
"npm": "@ai-sdk/anthropic",
"name": "Alibaba Cloud Model Studio",
"options": {
"baseURL": "https://coding.dashscope.aliyuncs.com/apps/anthropic/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"qwen3.7-plus": {
"name": "Qwen3.7 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 1024
}
}
},
"qwen3.6-plus": {
"name": "Qwen3.6 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 1024
}
}
},
"qwen3.5-plus": {
"name": "Qwen3.5 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 1024
}
}
},
"qwen3-max-2026-01-23": {
"name": "Qwen3 Max 0123"
},
"qwen3-coder-next": {
"name": "Qwen3 Coder Next"
},
"qwen3-coder-plus": {
"name": "Qwen3 Coder Plus"
},
"MiniMax-M2.5": {
"name": "MiniMax M2.5"
},
"glm-5": {
"name": "GLM-5",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 1024
}
}
},
"glm-4.7": {
"name": "GLM-4.7"
},
"kimi-k2.5": {
"name": "Kimi K2.5",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 1024
}
}
}
}
}
}
}
Pay-as-you-go
Replace YOUR_API_KEY with your Alibaba Cloud Model Studio API key. For a list of available models, see Anthropic compatible API.
The baseURL is region-specific, replace {WorkspaceId} in the URL with your actual Workspace ID. Ensure that your API key corresponds to the selected region:
-
China (Beijing):
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1 -
Singapore:
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"bailian-payg": {
"npm": "@ai-sdk/anthropic",
"name": "Alibaba Cloud Model Studio",
"options": {
"baseURL": "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"qwen3.7-max": {
"name": "Qwen3.7 Max",
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"qwen3.7-plus": {
"name": "Qwen3.7 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"qwen3.6-plus": {
"name": "Qwen3.6 Plus",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"deepseek-v3.2": {
"name": "DeepSeek V3.2"
}
}
}
}
}
To add other models, append them to the models object in the same format.
Verify the configuration
After saving the configuration file, restart OpenCode. Enter /models, search for Alibaba Cloud Model Studio, then select a model to start a conversation.
FAQ
Error codes
If you encounter an error during configuration, refer to the FAQ for your billing method:
-
Pay-as-you-go: Anthropic compatible API - error codes
-
Coding Plan: Coding Plan FAQ
-
Token Plan Personal Edition: Token Plan Personal Edition FAQ
-
Token Plan Team Edition: Token Plan Team Edition FAQ