OpenCode
更新时间 2026-04-27 16:45:14
最近更新时间: 2026-04-27 16:45:14
配置模型
请在以下路径创建并打开配置文件 opencode.json:
macOS / Linux: ~/.config/opencode/opencode.json
Windows: C:\Users\您的用户名\.config\opencode\opencode.json
将以下配置写入文件,关键配置项:
YOUR_API_KEY为你服务组的API Key。
models的配置则为 来源于您当前实际可用的模型,以下示例配置以GLM-5-Pro为例。
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"xirang": {
"npm": "@ai-sdk/openai-compatible",
"name": "xirang",
"options": {
"baseURL": "https://wishub-x6.ctyun.cn/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"GLM-5-Pro": {
"name": "GLM-5-Pro"
},
"DeepSeek-V3.2-Pro": {
"name": "DeepSeek-V3.2-Pro"
}
}
}
},
"model": "xirang/GLM-5-Pro",
"small_model": "xirang/GLM-5-Pro"
}运行 opencode 启动 OpenCode
在命令行中输入以下命令:
$ opencode使用 /models 命令来选择模型,例如 GLM-5。
/models