一、前置条件
在开始配置前,确保你已完成以下准备工作:
1. 订阅 Token Plan 企业版套餐。
2. 获取模型配置:
2.1 专业套餐模型配置。
2.2 轻享套餐模型配置。
3. 获取 API Key。
4. 安装 OpenCode:请参见 OpenCode 安装指南,你可以选择桌面应用版下载;也可以在命令行中执行以下命令安装:
npm install -g opencode-ai
安装完成后,执行以下命令检查,输出版本号则表示安装成功:
opencode -v
二、配置模型
OpenCode 支持通过桌面客户端或命令行配置文件接入腾讯云 Token Plan 企业版,两种方式任选其一即可。
三、方式一:桌面客户端配置
1. 打开 OpenCode,在对话界面,单击管理模型打开模型设置界面。
2. 在打开的弹窗中,单击+ 连接提供商,选择自定义 OpenAI 兼容提供商。
3. 在打开的弹窗中,点击填写信息并提交:
·提供商 ID:tencent
·显示名称:Tencent TokenPlan
·基础 URL:https://tokenhub.tencentmaas.com/plan/v3
·API 密钥:填写你的 API Key。
·model-id 和模型:根据你购买的套餐,填入套餐支持的模型 ID。
·专业套餐模型配置
·轻享套餐模型配置
4. 在对话窗口的模型列表中,找到并选定新配置的模型,即可进行对话使用。
四、方式二:命令行配置
1. 修改 OpenCode 的配置文件,配置文件路径如下,配置文件不存在时新建即可。
·macOS / Linux:~/.config/opencode/opencode.json
·Windows:C:\\Users\\<用户名>\\.config\\opencode\\opencode.json
2. 将以下内容复制粘贴到 opencode.json 文件中并保存。请你将 $your_api_key 替换为 Token Plan 专属的 API Key。下方配置已按专业套餐预填模型列表;轻享套餐用户请将 models 替换为第 3 步给出的轻享配置:
{ "$schema": "https://opencode.ai/config.json", "provider": { "tencent": { "npm": "@ai-sdk/openai-compatible", "name": "Tencent TokenPlan", "options": { "baseURL": "https://tokenhub.tencentmaas.com/plan/v3", "apiKey": "$your_api_key" }, "models": { "auto": { "name": "Auto", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "glm-5.3-flash": { "name": "GLM-5.3-Flash", "modalities": { "input": ["text", "image"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "glm-5.3": { "name": "GLM-5.3", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "glm-5.2": { "name": "GLM-5.2", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "kimi-k3": { "name": "Kimi K3", "modalities": { "input": ["text", "image"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "kimi-k2.7-code": { "name": "Kimi K2.7 Code", "modalities": { "input": ["text", "image"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "kimi-k2.7-code-highspeed": { "name": "Kimi K2.7 Code HighSpeed", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "kimi-k2.6": { "name": "Kimi-K2.6", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "minimax-m2.7": { "name": "MiniMax-M2.7", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "minimax-m3": { "name": "MiniMax-M3", "modalities": { "input": ["text", "image"], "output": ["text"] } }, "deepseek-v4-pro": { "name": "DeepSeek-V4-Pro", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "deepseek-v4-pro-0813": { "name": "DeepSeek-V4-Pro 0813 正式版", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "deepseek-v4-flash-202605": { "name": "DeepSeek-V4-Flash 正式版 原厂直供", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "deepseek-v4-pro-202606": { "name": "DeepSeek-V4-Pro 正式版 原厂直供", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }, "deepseek/deepseek-v4-flash-vision-exp": { "name": "DeepSeek-V4-Flash-Vision-Exp 原厂直供", "modalities": { "input": ["text", "image"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } } } } }}
3. 轻享套餐用户请将上方配置中的 models 整段替换为以下内容(轻享套餐仅提供 Auto 智能路由):
"models": { "auto": { "name": "Auto", "modalities": { "input": ["text"], "output": ["text"] }, "options": { "thinking": { "type": "enabled" } } }}
4. 在终端执行以下命令启动 OpenCode:
opencode
5. 输入 /models,选择配置的模型,即可开始对话使用。
注意:说明:
注意:模型列表:专业套餐支持模型请参见 专业套餐模型配置,轻享套餐请参见 轻享套餐模型配置。套餐模型为动态更新的模型库,请以源页面为准,按上述条目格式在 models 中增减即可。配置 Model ID 时,必须使用全小写格式。