深度研究Agent对话
更新时间:2025-12-12
POST
https://qianfan.baidubce.com/v2/agent/deepresearch/run
本接口用于与“深度研究”智能体进行多轮流式对话。“深度研究”是一个涉及多步推理与执行的长流程任务,不同于普通的“一问一答”。其完整的执行生命周期包含以下环节:
- 发起研究:用户输入研究问题,支持上传背景文件(可选)。
- 需求澄清:若用户请求研究的问题模糊、不完整或存在歧义,Agent多次主动与用户交互,通过提问来明确研究方向与方法。
- 大纲生成与确认:Agent生成研究大纲,用户可修改或确认。
- 深度执行:Agent将复杂问题逐步拆解,再结合联网信息及上传文件的混合检索拆解解决问题。
- 报告生成:输出长文本研究报告。
权限说明
调用本文API,需使用API Key鉴权方式。使用API Key鉴权调用API流程,具体调用流程,请查看认证鉴权。
请求参数
Headers 参数
除公共头域外,无其它特殊头域
Body 参数
query
string
输入的对话信息。根据用户输入的 Query 判断是简单问答还是进行深度研究。
必选
file_ids
array
传入的文件 ID 列表。
请确保文件已依次完成以下步骤:
可选
显示子属性
隐藏子属性
items
string
interrupt_id
string
中断/干预 ID。
在回复 Agent 的"需求澄清"或"大纲确认"请求时必填。该字段内容在上一轮 SSE 响应中 content.text.data 字段内获取。
可选
conversation_id
string
对话ID。
首轮对话:可不填,由服务端自动生成并在响应中返回,也可通过对话创建接口预先获取对话ID。
后续对话:必须填写,以保持上下文连续性,可在sse数据流获取conversation_id。
可选
structured_outline
object {4}
深度研究报告的结构化大纲。
若上一轮对话输出为大纲确认数据,用户可基于大纲内容进行修改,下一轮对话请求携带最终大纲即可。Agent 将严格依据此数据生成后续的研究报告。
可选
显示子属性
隐藏子属性
title
string
报告标题,可修改此字段以调整报告主题。
必选
locale
string
指定报告生成的目标语言,目前仅支持简体中文。
可选
description
string
报告摘要,指导 Agent 全文写作。
必选
sub_chapters
array
子章节列表,支持递归嵌套,章节当前支持2级展开。
必选
显示子属性
隐藏子属性
items
object {3}
显示子属性
隐藏子属性
title
string
章节标题。
必选
description
string
章节写作指引,可对章节内容、组织结构、语言风格等给出明确要求。
必选
sub_chapters
array
子章节列表,支持递归嵌套。
必选
显示子属性
隐藏子属性
items
object {0}
显示子属性
隐藏子属性
暂无参数
请求结构
POST /v2/agent/deepresearch/run HTTP/1.1
HOST: qianfan.baidubce.com
Authorization: Bearer <API Key>
Content-Type: application/json
{
"query": "研究大模型市场规模"
}
示例代码
Curl
curl -i --location 'https://qianfan.baidubce.com/v2/agent/deepresearch/run' \
--header 'Authorization: Bearer bce-v3/ALTAK-********/86356c2efcefb5776024ddb7d7958640f2fc16bf' \
--header 'Content-Type: application/json' \
--data '{
"query": "研究AI市场"
}'
Curl
curl --location --request POST 'https://qianfan.baidubce.com/v2/agent/deepresearch/run' \
--header 'Authorization: Bearer bce-v3/ALTAK-********/86356c2efcefb5776024ddb7d7958640f2fc16bf' \
--header 'Content-Type: application/json' \
--data '{
"query": "跳过",
"conversation_id": "5f54660a-****-****-bc99-e0c0d6db8a7d",
"interrupt_id": "83e03dfa-****-****-80cb-1ee991c219ae"
}'
Curl
curl --location --request POST 'https://qianfan.baidubce.com/v2/agent/deepresearch/run' \
--header 'Authorization: Bearer bce-v3/ALTAK-********/86356c2efcefb5776024ddb7d7958640f2fc16bf' \
--header 'Content-Type: application/json' \
--data '{
"query": "确认",
"conversation_id": "5f54660a-****-****-bc99-e0c0d6db8a7d",
"interrupt_id": "83e03dfa-****-****-80cb-1ee991c219ae",
"structured_outline": {
"locale": "简体中文",
"title": "全球人工智能市场研究与战略分析报告",
"description": "本报告全面分析全球AI市场的发展现状、技术趋势、应用场景、竞争格局,并提供面向企业决策者、投资者和行业研究者的未来3-5年预测与投资建议。",
"sub_chapters": [
{
"title": "全球AI市场概述与技术趋势",
"description": "回顾过去5年AI市场发展,分析当前全球市场规模、增长驱动因素及核心技术趋势,包括大模型和多模态AI的演进。",
"sub_chapters": [
{
"title": "市场发展回顾与现状",
"description": "总结过去5年全球AI市场的关键里程碑、增长数据和主要推动力。",
"sub_chapters": []
},
{
"title": "核心技术趋势分析",
"description": "深入探讨大模型、多模态AI及智能体技术的最新进展和未来方向。",
"sub_chapters": []
},
{
"title": "增长驱动因素与挑战",
"description": "识别市场增长的主要动力(如投资、政策)和潜在风险(如技术瓶颈、伦理问题)。",
"sub_chapters": []
}
]
}
]
}
}'
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
响应参数
本接口响应数据参见通用对话响应参数接口文档。响应内容为 SSE 流式数据,每一行 (data:) 为一个 JSON 对象。
在Agent执行过程中,通过content.event.name字段来判断当前的执行阶段:
| 阶段 | 关键事件标识 | 逻辑说明 |
|---|---|---|
| 需求澄清 | /toolcall/interrupt |
Agent 挂起任务,主动向用户提问以收集关于研究范围的反馈。 |
| 大纲确认 | /toolcall/structured_outline |
Agent 生成初步报告大纲,并进入等待状态,等待用户对大纲的反馈与确认。 |
可选
JSON
data: {"role": "assistant", "status": "running", "content": [{"name": "/chat/chat_agent", "type": "text", "text": {"info": "您希望这份AI市场调研报告侧重于 **技术发展趋势**(如大模型、多模态),还是 **商业应用场景**(如金融、医疗)?"}, "event": {"id": "msg-01", "status": "running", "name": "/chat/chat_agent"}}]}
data: {"role": "assistant", "status": "running", "content": [{"name": "/chat/chat_agent", "type": "text", "text": {"info": "\n\n另外,您对报告的输出形式有特殊偏好吗?比如侧重数据图表,还是深度案例分析?"}, "event": {"id": "msg-01", "status": "running", "name": "/chat/chat_agent"}}]}
data: {"role": "assistant", "status": "running", "content": [{"name": "/chat/chat_agent", "type": "text", "text": {"info": "\n\n您也可以提出其他具体方向。如果您希望直接进入下一步,请输入“跳过”~"}, "event": {"id": "msg-01", "status": "running", "name": "/chat/chat_agent"}}]}
data: {"role": "assistant", "status": "done", "content": [{"name": "/chat/chat_agent", "type": "text", "text": {"info": ""}, "event": {"id": "msg-01", "status": "done", "name": "/chat/chat_agent"}}]}
data: {"role": "tool", "status": "interrupt", "content": [{"name": "/toolcall/interrupt", "type": "json", "text": {"data": "{\"interrupt_id\":\"1b6696fd-1f68-4a3e-a3e3-a6d771504f08\",\"interrupt_type\":\"deep_research_coordinator\",\"wait_for\":[\"query\"]}"}, "event": {"id": "evt-int-01", "status": "interrupt", "name": "/toolcall/interrupt"}}]}
JSON
data: {"role": "tool", "status": "done", "content": [{"type": "json", "name": "", "text": {"data": "{\"thinking\":\"研究主题是AI市场调研报告,核心需求是让我自行选择合适的调研维度来生成报告...\",\"locale\":\"简体中文\",\"title\":\"2025-2026年人工智能市场综合调研与趋势前瞻报告\",\"description\":\"本报告系统分析全球AI市场的规模结构、产业链生态...\",\"sub_chapters\":[{\"title\":\"全球AI市场总体规模与增长态势\",\"description\":\"综合分析全球及中国AI市场的整体规模...\",\"sub_chapters\":[...]}]}"}, "event": {"id": "f316fa4a-c6ec-4f88-97ae-2554afc78715", "status": "done", "name": "/toolcall/structured_outline"}}]}
data: {"role": "tool", "status": "interrupt", "content": [{"type": "json", "name": "", "text": {"data": "{\"interrupt_id\":\"1b6696fd-1f68-4a3e-a3e3-a6d771504f08\",\"interrupt_type\":\"deep_research_outliner\",\"wait_for\":[\"structured_outline\",\"query\"]}"}, "event": {"id": "6c57deb8-877c-4942-8e70-7cff37fbea88", "status": "interrupt", "name": "/toolcall/interrupt"}}]}
JSON
data: {"role": "tool", "status": "running", "content": [{"name": "/thought/plan", "type": "text", "text": {"info": "正在进行任务【AI市场调研报告】的规划。"}, "event": {"id": "d1d4ac0e-6153-43bb-8715-b9e8ce7f9029", "status": "running", "name": "/thought/plan"}}]}
data: {"role": "tool", "status": "running", "content": [{"name": "/thought/plan", "type": "plan", "text": {"tasks": [{"tool": "DeepSearchAgent", "id": "2214dbe5-d493-436c-a9fc-cc444b9076e1", "name": "全球AI市场规模、历史数据与驱动因素研究", "status": "preparing"}, {"name": "AI核心技术趋势与竞争格局深度分析", "status": "preparing", "tool": "DeepSearchAgent", "id": "40956565-f344-4bf0-ab94-6f4579388204"}, {"status": "preparing", "tool": "DeepSearchAgent", "id": "5f583630-ac62-4b0a-890b-660e2c3312e6", "name": "AI市场未来预测与战略建议信息收集"}]}, "event": {"id": "d1d4ac0e-6153-43bb-8715-b9e8ce7f9029", "status": "running", "name": "/thought/plan"}}]}
data: {"role": "tool", "status": "running", "content": [{"name": "/deep_search_agent", "type": "text", "text": {"info": "DeepSearch Agent1: 全球AI市场规模、历史数据与驱动因素研究"}, "event": {"id": "1f23e503-ce73-4e35-914a-babdf111ffc6", "status": "running", "name": "/deep_search_agent"}}]}
data: {"role": "tool", "status": "done", "content": [{"name": "/toolcall/baidu_search", "type": "references", "text": {"title": "IDC:全球人工智能总投资规模有望在2029年增长至12619亿美元", "content": "数据显示,2024年全球人工智能总投资规模为3159亿美元,"}, "event": {"id": "270b4ed6-174e-4a66-8601-0ab53a550d72", "status": "done", "name": "/toolcall/baidu_search"}}]}
data: {"role": "tool", "status": "done", "content": [{"name": "/toolcall/baidu_search", "type": "references", "text": {"title": "IDC:2024年全球人工智能IT总投资规模为3158亿美元 有望在2028年增至8159亿美元", "content": " IDC数据显示,2024年全球人工智能(AI)IT总投资规模为3,158亿美元,并有望在2028年增至8,159亿美元,五年复合增长率(CAGR)为32.9%。"}, "event": {"id": "b764b187-720a-4ce5-b843-8a6ef41129ae", "status": "done", "name": "/toolcall/baidu_search"}}]}
data: {"role": "tool", "status": "done", "content": [{"name": "/toolcall/baidu_search", "type": "references", "text": {"title": "斯坦福 AI 指数报告发布:2024年美国 AI 私人投资约为中国的 12 倍、GPT3.5 级别模型推理成本下降 280 倍", "content": "2024年全球私人AI投资达2523亿美元,其中生成式AI吸引339亿美元,同比增长18.7%。"}, "event": {"id": "97152d46-f8bb-4ce9-86ef-4812937bc8ca", "status": "done", "name": "/toolcall/baidu_search"}}]}
data: {"role": "tool", "status": "done", "content": [{"name": "/toolcall/crawl", "type": "text", "text": {"info": "### DeepSeek与主流大模型性能参数深度解析:技术选型指南\n\n**1.1 架构设计差异** \nDeepSeek采用混合专家模型(MoE)架构..."}, "event": {"id": "16527614-1326-49b8-954f-09ab05f90a90", "status": "done", "name": "/toolcall/crawl"}}]}
data: {"role": "tool", "status": "done", "content": [{"name": "/toolcall/structured_outline", "type": "json", "text": {"data": "{\"thinking\":\"研究主题为‘AI市场调研报告’...\",\"title\":\"AI市场全景调研与发展趋势分析报告\",\"sub_chapters\":[{\"title\":\"AI市场宏观概览与规模分析\",\"sub_chapters\":[...]}]}"}, "event": {"id": "ded1a16c-9911-4d76-b731-84f1a23c8852", "status": "done", "name": "/toolcall/structured_outline"}}]}
