OpenCode 是一款开源 AI 编程工具,本文介绍如何在 OpenCode 中配置与使用腾讯知识引擎 Token Plan。
前置条件
在开始配置前,请确保您已完成以下准备工作:
1. 订阅 Token Plan 套餐:前往腾讯云控制台 订阅 Token Plan 套餐。
2. 获取 API Key:购买成功后,在控制台 获取专属 API Key。
3. 支持模型列表:请参见 模型列表。
安装 OpenCode
执行如下命令安装。
npm install -g opencode-ai
安装完成后执行如下命令检查,输出版本号则表示安装成功。
opencode -v
配置 Token Plan
按照下面的示例修改 OpenCode 的配置文件,注意替换 <USER_API_KEY>,注意示例配置中以 glm-5 为例。
说明:
配置文件的路径如下:
macOS / Linux:
~/.config/opencode/opencode.json。Windows:
C:\\Users\\您的用户名\\.config\\opencode\\opencode.json。{"$schema": "https://opencode.ai/config.json","provider": {"myprovider": {"npm": "@ai-sdk/openai-compatible","name": "lkeap","options": {"baseURL": "https://api.lkeap.cloud.tencent.com/plan/v3","apiKey": "<USER_API_KEY>"},"models": {"tc-code-latest": {"name": "Auto","modalities": {"input": ["text"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 196608,"output": 32768}},"hunyuan-2.0-instruct": {"name": "Tencent HY 2.0 Instruct","modalities": {"input": ["text"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 128000,"output": 16000}},"hunyuan-2.0-thinking": {"name": "Tencent HY 2.0 Think","modalities": {"input": ["text"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 128000,"output": 32000}},"hunyuan-t1": {"name": "Hunyuan-T1","modalities": {"input": ["text"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 64000,"output": 32000}},"hunyuan-turbos": {"name": "hunyuan-turbos","modalities": {"input": ["text"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 32000,"output": 16000}},"minimax-m2.5": {"name": "MiniMax-M2.5","modalities": {"input": ["text"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 196608,"output": 32768}},"kimi-k2.5": {"name": "Kimi-K2.5","modalities": {"input": ["text","image"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 262144,"output": 32768}},"glm-5": {"name": "GLM-5","modalities": {"input": ["text"],"output": ["text"]},"options": {"thinking": {"type": "enabled","budgetTokens": 8192}},"limit": {"context": 202752,"output": 16384}}}}}}
使用 OpenCode
用如下命令启动 OpenCode。
opencode
输入/models,选择配置的模型并在 OpenCode 中使用。


开始使用 OpenCode。

