OpenCode

最近更新时间:2026-06-26 18:12:00

我的收藏
OpenCode 是一款开源的 AI 编程代理工具,提供终端界面、桌面应用和 IDE 扩展等多种使用方式。本文介绍如何在 OpenCode 中配置与使用腾讯云大模型 Token Plan 企业版。

前置条件

在开始配置前,确保您已完成以下准备工作:

安装 OpenCode

执行如下命令安装 OpenCode,更多操作可参考 OpenCode 官方配置指引
npm install -g opencode-ai
安装完成后,您可以执行如下命令检查,输出版本号则表示安装成功。
opencode -v

配置 Token Plan 企业版

您需要按照下面的示例修改 OpenCode 的配置文件,配置文件路径如下,配置文件不存在时新建即可。
macOS / Linux:~/.config/opencode/opencode.json
Windows:C:\\Users\\<用户名>\\.config\\opencode\\opencode.json
说明:
请您将代码中 <USER_API_KEY> 替换为您的 API Key。下方配置已根据套餐类型预填了 models 列表,可按需保留所需模型。
配置专业套餐
配置轻享套餐
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "Tencent Cloud Token Plan 企业版 专业套餐",
"options": {
"baseURL": "https://tokenhub.tencentmaas.com/plan/v3",
"apiKey": "<USER_API_KEY>"
},
"models": {
"auto": {
"name": "Auto",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 196608,
"output": 32768
}
},
"glm-5": {
"name": "GLM-5",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 204800,
"output": 131072
}
},
"glm-5.1": {
"name": "GLM-5.1",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 204800,
"output": 131072
}
},
"glm-5.2": {
"name": "GLM-5.2",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 1048576,
"output": 131072
}
},
"glm-5-turbo": {
"name": "GLM-5-Turbo",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 204800,
"output": 131072
}
},
"kimi-k2.5": {
"name": "Kimi-K2.5",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 262144,
"output": 262144
}
},
"kimi-k2.6": {
"name": "Kimi-K2.6",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 262144,
"output": 262144
}
},
"minimax-m2.5": {
"name": "MiniMax-M2.5",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 204800,
"output": 131072
}
},
"minimax-m2.7": {
"name": "MiniMax-M2.7",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 204800,
"output": 131072
}
},
"minimax-m3": {
"name": "MiniMax-M3",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 1048576,
"output": 131072
}
},
"deepseek-v4-flash": {
"name": "DeepSeek-V4-Flash",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 1048576,
"output": 393216
}
},
"deepseek-v4-pro": {
"name": "DeepSeek-V4-Pro",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 1048576,
"output": 393216
}
},
"deepseek-v4-flash-202605": {
"name": "DeepSeek-V4-Flash 原厂直供",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 1048576,
"output": 393216
}
},
"deepseek-v4-pro-202606": {
"name": "DeepSeek-V4-Pro 原厂直供",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 1048576,
"output": 393216
}
}
}
}
}
}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "Tencent Cloud Token Plan 企业版 轻享套餐",
"options": {
"baseURL": "https://tokenhub.tencentmaas.com/plan/v3",
"apiKey": "<USER_API_KEY>"
},
"models": {
"auto": {
"name": "Auto",
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
},
"limit": {
"context": 196608,
"output": 32768
}
}
}
}
}
}

使用 OpenCode

执行如下命令启动 OpenCode:
opencode
输入/models,选择配置的模型并在 OpenCode 中使用。
完成上述配置后,即可开始使用 OpenCode。

开始对话