文章摘要
DeepSeek API兼容OpenAI/Anthropic格式,只需修改配置即可使用其SDK或兼容软件访问。需申请API密钥,并指定模型名称(部分旧模型将于2026年7月24日停用)。提供OpenAI格式的调用示例,支持流式和非流式响应,Anthropic格式调用参考相关文档。
文章总结
标题:首次调用DeepSeek API | DeepSeek API文档
DeepSeek API采用与OpenAI/Anthropic兼容的接口格式。通过调整配置,用户可直接使用OpenAI/Anthropic的SDK或兼容工具调用DeepSeek API。
关键参数配置
| 参数 | 值 |
|---------------|-------------------------------------------------------------------|
| baseurl (OpenAI) | https://api.deepseek.com |
| baseurl (Anthropic) | https://api.deepseek.com/anthropic |
| api_key | 需申请API密钥 |
| model* | deepseek-v4-flash、deepseek-v4-pro、即将废弃的deepseek-chat(2026/07/24停用)及deepseek-reasoner(同前) |
*注:
deepseek-chat和deepseek-reasoner将分别对应deepseek-v4-flash的非思考模式与思考模式,未来建议迁移至新模型。
调用聊天API
获取API密钥后,可通过OpenAI格式的示例代码调用模型。以下为非流式请求示例(设置stream: true可启用流式响应):
cURL示例
bash
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"thinking": {"type": "enabled"},
"reasoning_effort": "high",
"stream": false
}'
如需Anthropic格式的调用方式,请参阅Anthropic API指南。
(注:原文中的Python和Node.js代码示例因与核心说明关联较弱,此处略去以保持简洁。)
评论总结
总结评论内容:
模型发布与性能表现
- 评论指出DeepSeek-V4-Pro已发布,性能达到前沿水平,成本更低。
"Model was released and it's amazing. Frontier level (better than Opus 4.6) at a fraction of the cost." (nthypes)
"MMLU-Pro: Gemini-3.1-Pro at 91.0, Opus-4.6 at 89.1, GPT-5.4, Kimi2.6, and DS-V4-Pro tied at 87.5." (Aliabid94)
- 评论指出DeepSeek-V4-Pro已发布,性能达到前沿水平,成本更低。
技术细节与优化
- 评论提到模型采用了创新的神经网络架构优化(如mHC和混合注意力机制)。
"One of the key points is the optimization with the residual design... manifold-constrained hyper-connections (mHC)." (rvz)
"KV cache is said to take 10% as much space as V3." (zargon)
- 评论提到模型采用了创新的神经网络架构优化(如mHC和混合注意力机制)。
本地运行与量化需求
- 用户关注模型在本地设备(如MacBook)上的运行可能性和量化版本的需求。
"How long does it usually take for folks to make smaller distills of these models?" (ls612)
"Is there a Quantized version of this?" (namegulf)
- 用户关注模型在本地设备(如MacBook)上的运行可能性和量化版本的需求。
多模态与功能缺失
- 部分用户对模型缺乏原生多模态支持表示遗憾。
"Excited that the long awaited v4 is finally out. But feel sad that it's not multimodal native." (jdeng)
- 部分用户对模型缺乏原生多模态支持表示遗憾。
开源与中国背景
- 评论提到模型的开源性质及其中国背景,部分用户持积极态度。
"Truly open source coming from China. This is heartwarming." (sidcool)
- 评论提到模型的开源性质及其中国背景,部分用户持积极态度。
行业动态与用户疲劳
- 用户对AI领域快速更新感到疲劳,并希望有工具帮助跟进。
"I could really use a support group for people burnt out from trying to keep up with everything." (gbnwl)
"At this point 'frontier model release' is a monthly cadence." (jessepcc)
- 用户对AI领域快速更新感到疲劳,并希望有工具帮助跟进。
价格与可用性
- 评论提到模型已在OpenRouter上线,价格相对较低。
"Pro version is $1.74/m/input, $3.48/m/output, while flash $0.14/m/input, 0.28/m/output." (yanis_t)
- 评论提到模型已在OpenRouter上线,价格相对较低。
开发者文档先行
- 用户赞赏开发者文档先于正式发布的做法。
"There's something heartwarming about the developer docs being released before the flashy press release." (fblp)
- 用户赞赏开发者文档先于正式发布的做法。
短期热度与长期关注
- 有评论预测模型短期内会引发热议,但可能很快被遗忘。
"DeepSeek4 floods every AI-related online space... Then a few weeks later it'll be forgotten by most." (raincol)
- 有评论预测模型短期内会引发热议,但可能很快被遗忘。
基准测试与验证
- 用户建议等待独立验证,而非完全信任官方基准测试。
"I wouldn’t trust the benchmarks directly, but would wait for others to try it." (rvz)
- 用户建议等待独立验证,而非完全信任官方基准测试。
硬件需求与成本
- 用户讨论在自有硬件上运行模型的可行性及成本。
"How can you reasonably try to get near frontier on hardware you own? Maybe under 5k in cost?" (aliljet)
- 用户讨论在自有硬件上运行模型的可行性及成本。
模型比较与偏好
- 有用户对比不同版本(如Flash与Pro)的输出效果,表达个人偏好。
"I like the pelican I got out of deepseek-v4-flash more than the one from deepseek-v4-pro." (simonw)
- 有用户对比不同版本(如Flash与Pro)的输出效果,表达个人偏好。
总结:
评论普遍认可DeepSeek-V4-Pro的性能和成本优势,同时关注技术细节、本地运行可能性和行业影响。部分用户对多模态缺失和快速迭代的疲劳表示担忧,而开源背景和开发者文档先行获得积极评价。价格和量化版本的需求也是讨论焦点。