就在刚刚,DeepSeek V4 已经正式发布,但是如果你打开 OpenCode,会发现无论是已创建好的 DeepSeek 连接还是新建 DeepSeek 连接,都没有显示 V4 的模型,这是因为 OpenCode 还不支持默认加载最新模型(还在改 bug 呢)。
我们无法知道 OpenCode 这些 bug 要改到哪个猴年马月,但用下面的方法,可以让我们先快速集成 V4 模型进行体验使用。
建立连接
和原来的流程一样,打开 OpenCode,输入如下命令:
/connect
然后根据弹出的页面选择 DeepSeek,就会让你输入 DeepSeek 的 API Key 了。
这时我们只需要登录到 DeepSeek 的网站生成一个 API Key。
然后将它复制到 OpenCode 中,这时连接就建立好了,但是不出所料,它还只有 V3 的模型可用,还需要通过修改配置文件来让 OpenCode 加载 DeepSeek V4 模型。
修改 ~/.config/opencode/opencode.json(最新版本可能叫 opencode.jsonc),用 vim 或 VSCode 等编辑器打开文件,添加如下内容到 provider 下:
"deepseek":{
"npm": "@ai-sdk/anthropic",
"name": "DeepSeek",
"options": {
"baseURL": "https://api.deepseek.com/anthropic"
},
"models": {
"deepseek-v4-pro": {
"name": "DeepSeek-V4-Pro",
"limit": {
"context": 1048576,
"output": 262144
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
},
"deepseek-v4-flash": {
"name": "DeepSeek-V4-Flash",
"limit": {
"context": 1048576,
"output": 262144
},
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 8192
}
}
}
}
}
最终你得到的 opencode.jsonc 配置结构如下:
{
"plugin": [...
], // 你接入的插件列表
"$schema": "https://opencode.ai/config.json",
"disabled_providers": [],
"provider": {
"aliyun": {...
}, // 如果你接入了阿里云的coding plan
"deepseek": {...
} // 我们新增的deepseek接入配置
}
}
重启你的 OpenCode,就可以启用 V4 模型啦!