OpenCode 接入 DeepSeek V4
- 内容介绍
- 文章标签
- 相关推荐
想试试 DeepSeek V4,扔给 GPT-5.4 让它帮我配 OpenCode。折腾了 20 分钟,踩了两个坑,记录一下。
第一步:选对入口
DeepSeek 现在有两个模型:
deepseek-v4-pro— 主力deepseek-v4-flash— 快速便宜
端点我用的是 https://api.deepseek.com/beta,实测比 /v1 顺,没遇到奇怪的兼容问题。
第二步:配 provider
OpenCode 里不要复用现有的 openai 或 anthropic provider,直接新建一个:
"aic":{
"npm":"@ai-sdk/openai-compatible",
"name":"兼容奥",
"options":{"baseURL":"https://api.deepseek.com/beta","apiKey":"sk-xxx","includeUsage":true},
"models":{
"deepseek-v4-pro":{
"name":"DeepSeek V4 Pro",
"attachment":true,"reasoning":true,
"interleaved":{"field":"reasoning_content"},
"modalities":{"input":["text"],"output":["text"]},
"limit":{"context":1000000,"output":384000},
"options":{"extra_body":{"thinking":{"type":"disabled"}}},
"variants":{
"high":{"reasoning_effort":"high","extra_body":{"thinking":{"type":"enabled"}}},
"xhigh":{"reasoning_effort":"max","extra_body":{"thinking":{"type":"enabled"}}}
},
"cost":{"input":0.44,"output":0.88,"cache_read":0.0037}
},
"deepseek-v4-flash":{
"name":"DeepSeek V4 Flash",
"attachment":true,"reasoning":true,
"interleaved":{"field":"reasoning_content"},
"modalities":{"input":["text"],"output":["text"]},
"limit":{"context":1000000,"output":384000},
"options":{"extra_body":{"thinking":{"type":"disabled"}}},
"variants":{
"high":{"reasoning_effort":"high","extra_body":{"thinking":{"type":"enabled"}}}
},
"cost":{"input":0.147,"output":0.293,"cache_read":0.0029}
}
}
}
踩坑记录
坑一:选错 npm 包
一开始想挂到 aio(@ai-sdk/openai)下面。原因是 OpenCode 的 openai provider 走的是 /v1/responses,DeepSeek 只支持 /v1/chat/completions。GPT-5.4 直接告诉我换 @ai-sdk/openai-compatible,立竿见影。
坑二:思考模式下报 400
配好之后一切到 high variant 就报这个:
"The reasoning_content in the thinking mode must be passed back to the API."
DeepSeek 思考模式要求每轮请求必须把上一轮的思维链带回去。OpenCode 默认不干这事。
解法是模型配置里加一行:
"interleaved":{"field":"reasoning_content"}
加了之后多轮对话、工具调用都正常了。这个字段在 OC 文档里没怎么提,是翻 GitHub issue #6040 翻出来的。
一些选择
- 默认关思考:日常够用,省 token。需要深度推理时切 variant
- variant 命名:
high/xhigh,和 OC 其他模型统一 - flash 不给 xhigh:定位是快速模型,开满思考没意义
- 成本按美元写:DeepSeek 定价是人民币,按 6.82 换算的,差不多就行
PS: 昨晚犯二了,,,dsv4 应该是不支持多模态
网友解答:--【壹】--:
image1370×819 36.7 KB
--【贰】--: ufhy:
果用官方本来自带的那一个 供应商 的接入的话, 会有什么问题
我让它自己做了源码实现比较基本是一致的,只是我的配置更细一些
我都是放到自己的中转,再使用,这样配置文件会比较干净,各个厂商的key都在自己的中转里面,算是个洁癖吧
--【叁】--:
这个 400 报错真的很迷惑,看到 reasoning_content 那行才像是找到开关了
--【肆】--:
opencode比claude
code更好吗?请问
--【伍】--:
谢谢分享,可能beta的路线是比较新的策略?
--【陆】--:
我跟佬一样也主力使用opencode,这玩意好像有个模型白名单,从medels.dev获取的,dsv4刚出来那天死活不在我的模型列表里,手动添加也不行,第二天madels.dev添加了才好
--【柒】--:
opencode cli 中 /connect 中有 Deepseek, 选择输入 token,最新版本的的就有 V4 模型
--【捌】--:
好奇, 我记得官网不是应该比较早的提供支持了吗?如果用官方本来自带的那一个 供应商 的接入的话, 会有什么问题呢现在
--【玖】--:
image716×184 3.88 KB
大赞这个帖子,刚刚出现这个报错,加了 "field": "reasoning_content" 也没用,想着来这里必有解决之法,结果关键是这两个:
"npm":"@ai-sdk/openai-compatible",
"baseURL":"https://api.deepseek.com/beta"
--【拾】--:
"interleaved":{"field":"reasoning_content"}这个字段应该是新出的,opencode 1.14.18 会提示不支持该字段,我升级到1.14.28才用上
--【拾壹】--:
deepseek官方api需要实名验证才能充值,不想搞实名认证有什么路子吗
--【拾贰】--:
感谢感谢 还是L站能学到真东西 那个400报错一直不知道怎么解决
--【拾叁】--:
感谢大佬学到了,之前遇到那个"The reasoning_content in the thinking mode must be passed back to the API."报错死活不会解决,还以为是DeepSeek的锅这下解惑了
--【拾肆】--:
升级opencode最新版,不配interleaved也可以用了
--【拾伍】--:
估计受限于训练数据吧,需要补充基础知识才能比较好的工作
--【拾陆】--:
deepseek 官网就有配置教程,不要叫gpt帮忙配置啦
--【拾柒】--:
v4在opencode中的表现怎么样呢?
--【拾捌】--:
收藏一下,现在主力都是用opencode了,公司虚拟机多,都是各种服务器测试机,随后一个npm装个oc去解决问题
--【拾玖】--:
没有吧,我感觉还是claude的上下文要更好一丢丢,不过差别不是特别大,还有oc内存占用也是头疼的问题
想试试 DeepSeek V4,扔给 GPT-5.4 让它帮我配 OpenCode。折腾了 20 分钟,踩了两个坑,记录一下。
第一步:选对入口
DeepSeek 现在有两个模型:
deepseek-v4-pro— 主力deepseek-v4-flash— 快速便宜
端点我用的是 https://api.deepseek.com/beta,实测比 /v1 顺,没遇到奇怪的兼容问题。
第二步:配 provider
OpenCode 里不要复用现有的 openai 或 anthropic provider,直接新建一个:
"aic":{
"npm":"@ai-sdk/openai-compatible",
"name":"兼容奥",
"options":{"baseURL":"https://api.deepseek.com/beta","apiKey":"sk-xxx","includeUsage":true},
"models":{
"deepseek-v4-pro":{
"name":"DeepSeek V4 Pro",
"attachment":true,"reasoning":true,
"interleaved":{"field":"reasoning_content"},
"modalities":{"input":["text"],"output":["text"]},
"limit":{"context":1000000,"output":384000},
"options":{"extra_body":{"thinking":{"type":"disabled"}}},
"variants":{
"high":{"reasoning_effort":"high","extra_body":{"thinking":{"type":"enabled"}}},
"xhigh":{"reasoning_effort":"max","extra_body":{"thinking":{"type":"enabled"}}}
},
"cost":{"input":0.44,"output":0.88,"cache_read":0.0037}
},
"deepseek-v4-flash":{
"name":"DeepSeek V4 Flash",
"attachment":true,"reasoning":true,
"interleaved":{"field":"reasoning_content"},
"modalities":{"input":["text"],"output":["text"]},
"limit":{"context":1000000,"output":384000},
"options":{"extra_body":{"thinking":{"type":"disabled"}}},
"variants":{
"high":{"reasoning_effort":"high","extra_body":{"thinking":{"type":"enabled"}}}
},
"cost":{"input":0.147,"output":0.293,"cache_read":0.0029}
}
}
}
踩坑记录
坑一:选错 npm 包
一开始想挂到 aio(@ai-sdk/openai)下面。原因是 OpenCode 的 openai provider 走的是 /v1/responses,DeepSeek 只支持 /v1/chat/completions。GPT-5.4 直接告诉我换 @ai-sdk/openai-compatible,立竿见影。
坑二:思考模式下报 400
配好之后一切到 high variant 就报这个:
"The reasoning_content in the thinking mode must be passed back to the API."
DeepSeek 思考模式要求每轮请求必须把上一轮的思维链带回去。OpenCode 默认不干这事。
解法是模型配置里加一行:
"interleaved":{"field":"reasoning_content"}
加了之后多轮对话、工具调用都正常了。这个字段在 OC 文档里没怎么提,是翻 GitHub issue #6040 翻出来的。
一些选择
- 默认关思考:日常够用,省 token。需要深度推理时切 variant
- variant 命名:
high/xhigh,和 OC 其他模型统一 - flash 不给 xhigh:定位是快速模型,开满思考没意义
- 成本按美元写:DeepSeek 定价是人民币,按 6.82 换算的,差不多就行
PS: 昨晚犯二了,,,dsv4 应该是不支持多模态
网友解答:--【壹】--:
image1370×819 36.7 KB
--【贰】--: ufhy:
果用官方本来自带的那一个 供应商 的接入的话, 会有什么问题
我让它自己做了源码实现比较基本是一致的,只是我的配置更细一些
我都是放到自己的中转,再使用,这样配置文件会比较干净,各个厂商的key都在自己的中转里面,算是个洁癖吧
--【叁】--:
这个 400 报错真的很迷惑,看到 reasoning_content 那行才像是找到开关了
--【肆】--:
opencode比claude
code更好吗?请问
--【伍】--:
谢谢分享,可能beta的路线是比较新的策略?
--【陆】--:
我跟佬一样也主力使用opencode,这玩意好像有个模型白名单,从medels.dev获取的,dsv4刚出来那天死活不在我的模型列表里,手动添加也不行,第二天madels.dev添加了才好
--【柒】--:
opencode cli 中 /connect 中有 Deepseek, 选择输入 token,最新版本的的就有 V4 模型
--【捌】--:
好奇, 我记得官网不是应该比较早的提供支持了吗?如果用官方本来自带的那一个 供应商 的接入的话, 会有什么问题呢现在
--【玖】--:
image716×184 3.88 KB
大赞这个帖子,刚刚出现这个报错,加了 "field": "reasoning_content" 也没用,想着来这里必有解决之法,结果关键是这两个:
"npm":"@ai-sdk/openai-compatible",
"baseURL":"https://api.deepseek.com/beta"
--【拾】--:
"interleaved":{"field":"reasoning_content"}这个字段应该是新出的,opencode 1.14.18 会提示不支持该字段,我升级到1.14.28才用上
--【拾壹】--:
deepseek官方api需要实名验证才能充值,不想搞实名认证有什么路子吗
--【拾贰】--:
感谢感谢 还是L站能学到真东西 那个400报错一直不知道怎么解决
--【拾叁】--:
感谢大佬学到了,之前遇到那个"The reasoning_content in the thinking mode must be passed back to the API."报错死活不会解决,还以为是DeepSeek的锅这下解惑了
--【拾肆】--:
升级opencode最新版,不配interleaved也可以用了
--【拾伍】--:
估计受限于训练数据吧,需要补充基础知识才能比较好的工作
--【拾陆】--:
deepseek 官网就有配置教程,不要叫gpt帮忙配置啦
--【拾柒】--:
v4在opencode中的表现怎么样呢?
--【拾捌】--:
收藏一下,现在主力都是用opencode了,公司虚拟机多,都是各种服务器测试机,随后一个npm装个oc去解决问题
--【拾玖】--:
没有吧,我感觉还是claude的上下文要更好一丢丢,不过差别不是特别大,还有oc内存占用也是头疼的问题

