浏览器使用Agent对话
更新时间:2026-01-07
POST
https://qianfan.baidubce.com/v2/agent/browser_use/run
本接口调用“浏览器使用”Agent。该 Agent 具备自动化操作浏览器的能力,可以根据用户指令访问网页,提取信息回答用户问题。
权限说明
调用本文API,需使用API Key鉴权方式。使用API Key鉴权调用API流程,具体调用流程,请查看认证鉴权。
请求参数
Headers 参数
除公共头域外,无其它特殊头域
请求结构
POST /v2/agent/browser_use/run HTTP/1.1
HOST: qianfan.baidubce.com
Authorization: Bearer <API Key>
Content-Type: application/json
{
"query": "北京今天天气如何?"
}
示例代码
请求示例
curl -i --location 'https://qianfan.baidubce.com/v2/agent/browser_use/run' \
--header 'Authorization: Bearer bce-v3/ALTAK-********/86356c2efcefb5776024ddb7d7958640f2fc16bf' \
--header 'Content-Type: application/json' \
--data '{
"query": "今日时事新闻"
}'
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
响应示例
data: {"role": "assistant", "status": "running", "content": [{"name": "/thought/thought_agent", "type": "text", "text": {"info": "用户询问北京今天的天气...需要调用浏览器工具搜索。"}, "event": {"id": "1", "status": "running", "name": "/thought/thought_agent"}}]}
data: {"role": "tool", "status": "running", "content": [{"name": "/toolcall/browser_use", "type": "browser", "text": {"status": "preparing", "thought": {"next_goal": "Navigate to weather.com"}, "action": [{"go_to_url": {"url": "https://weather.com", "new_tab": false}}], "screenshot": {"browser_url": "about:blank"}}, "event": {"id": "2", "status": "preparing", "name": "/toolcall/browser_use"}}]}
data: {"role": "tool", "status": "running", "content": [{"name": "/toolcall/browser_use", "type": "browser", "text": {"status": "success", "thought": {"next_goal": "Click 'Accept' to handle cookie consent."}, "action": [{"click_element": {"index": 11}}], "screenshot": {"url": "https://agi-dev-platform-file.bj.bcebos.com/.../screenshot_1.jpg", "file_id": "file-w6rudwik"}}, "event": {"id": "2", "status": "running", "name": "/toolcall/browser_use"}}]}
data: {"role": "tool", "status": "running", "content": [{"name": "/toolcall/browser_use", "type": "browser", "text": {"status": "success", "action": [{"done": {"text": "北京今日(2025年12月10日)天气实况:\n• 天气状况:晴朗\n• 当前温度:2°C...", "success": true}}]}, "event": {"id": "2", "status": "done", "name": "/toolcall/browser_use"}}]}
data: {"role": "assistant", "status": "running", "content": [{"name": "/chat/chat_agent", "type": "text", "text": {"info": "根据"}, "event": {"id": "6", "status": "running", "name": "/chat/chat_agent"}}]}
data: {"role": "assistant", "status": "running", "content": [{"name": "/chat/chat_agent", "type": "text", "text": {"info": "weather.com"}, "event": {"id": "6", "status": "running", "name": "/chat/chat_agent"}}]}
data: {"role": "assistant", "status": "running", "content": [{"name": "/chat/chat_agent", "type": "text", "text": {"info": "的数据,北京今天天气晴朗..."}, "event": {"id": "6", "status": "running", "name": "/chat/chat_agent"}}]}
data: {"role": "tool", "status": "done", "content": [], "conversation_id": "b041e3b3-...", "end_user_id": "", "message_id": "945dd3bb-..."}
