Deepseek Reasoner API 深度思考过程揭秘
站长注:详细介绍如何通过 reasoning_content 字段捕捉 Deepseek Reasoner API 的思考过程,以及在实际项目中的应用。

你是否好奇过 AI 是如何思考的?今天我们就来揭秘 Deepseek Reasoner API 的独特功能 —— 通过 reasoning_content
字段,让我们能够一窥 AI 的思考过程。
欢迎免费试用 API易,3 分钟跑通 API 调用 www.apiyi.com 支持 Deepseek Reasoner 等全系列模型,让开发更智能 注册即送 1.1 美金额度起,约 300万 Tokens的 deepseek-chat 额度体验。立即免费注册 www.apiyi.com
Deepseek Reasoner 的思考过程
Deepseek Reasoner 是一个专注于推理和深度思考的 AI 模型。与普通的对话模型不同,它会在给出答案的同时,展示其完整的思考过程。这个思考过程通过 API 响应中的 reasoning_content
字段呈现。
思考过程的捕捉
让我们看一个简单的示例:
curl https://vip.apiyi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 你的API易密钥" \
-d '{
"model": "deepseek-reasoner",
"stream": false,
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}'
API 响应示例:
{
"id": "76390811-c11b-48dd-b0c3-dcdffb6b37ac",
"object": "chat.completion",
"created": 1738477110,
"model": "deepseek-reasoner",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?",
"reasoning_content": "Okay, the user just said \"Hello!\". Let me think about how to respond.\n\nI should start with a friendly greeting. Maybe \"Hello! How can I assist you today?\" That sounds welcoming and opens the door for them to ask for help. Keep it simple and approachable. Avoid any technical jargon. Make sure the response is in English since they greeted in English. Don't add anything extra unless they ask more. Ready to send."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 101,
"total_tokens": 114,
"completion_tokens_details": {
"reasoning_tokens": 90
}
}
}
思考过程的解析
在响应中,我们可以看到两个关键部分:
- 最终回答:
content
字段"Hello! How can I assist you today?"
- 思考过程:
reasoning_content
字段"Okay, the user just said \"Hello!\". Let me think about how to respond. I should start with a friendly greeting..."
在项目中使用思考过程
1. Python 示例
from openai import OpenAI
client = OpenAI(
api_key="你的API易密钥",
base_url="https://vip.apiyi.com/v1"
)
response = client.chat.completions.create(
model="deepseek-reasoner",
messages=[
{"role": "user", "content": "分析一下 Python 和 JavaScript 的区别"}
]
)
# 获取最终答案
answer = response.choices[0].message.content
print("答案:", answer)
# 获取思考过程
reasoning = response.choices[0].message.reasoning_content
print("\n思考过程:", reasoning)
2. Node.js 示例
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: '你的API易密钥',
baseURL: 'https://vip.apiyi.com/v1'
});
async function getReasoningProcess() {
const response = await openai.chat.completions.create({
model: 'deepseek-reasoner',
messages: [
{ role: 'user', content: '分析一下 Python 和 JavaScript 的区别' }
]
});
const answer = response.choices[0].message.content;
const reasoning = response.choices[0].message.reasoning_content;
console.log('答案:', answer);
console.log('思考过程:', reasoning);
}
第三方客户端支持
目前已经有多个第三方客户端支持展示 Deepseek Reasoner 的思考过程,比如:
Chatbox 客户端
Chatbox 是一个流行的开源 AI 聊天客户端,它已经支持展示 Deepseek Reasoner 的思考过程:
- 在对话界面中,思考过程会以独立的区块显示
- 可以通过设置选择是否显示思考过程
- 支持思考过程的复制和分享
深度思考的最佳实践
1. 合理使用思考过程
- 开发调试:在开发阶段查看 AI 的推理逻辑
- 教育场景:展示 AI 的思考方式,帮助学习
- 质量控制:通过思考过程评估回答质量
2. 性能优化
注意 reasoning_content
会增加 token 消耗:
- 响应中的
reasoning_tokens
字段显示了思考过程消耗的 token 数 - 可以根据需要选择是否获取思考过程
3. 界面展示建议
如果你在开发自己的应用:
- 将思考过程和最终答案分开展示
- 提供显示/隐藏思考过程的选项
- 考虑添加思考过程的格式化展示
深度思考的应用场景
- 教育应用
- 展示问题解决的思路
- 帮助学生理解推理过程
- 提供学习方法的参考
- 开发调试
- 分析 AI 的决策过程
- 优化提示词
- 排查异常响应
- 内容创作
- 理解内容生成的逻辑
- 改进创作思路
- 获取更多创意灵感
总结
Deepseek Reasoner API 的思考过程捕捉功能为我们打开了一扇窗,让我们能够深入了解 AI 的思考方式。无论是在开发调试还是实际应用中,这个功能都能带来独特的价值。
欢迎免费试用 API易,3 分钟跑通 API 调用 www.apiyi.com 支持 Deepseek Reasoner 等全系列模型,让开发更智能
本文作者:API易团队 欢迎关注我们的更新,持续分享 AI 开发经验和最新动态。