查询工作流Agent的异步执行结果
更新时间:2025-12-19
POST
https://qianfan.baidubce.com/v2/app/chatflow/async/retrieve
通过execute_id,查询指定异步工作流Agent任务的执行结果,返回执行状态和详细内容。
权限说明
调用本文API,需使用API Key鉴权方式。使用API Key鉴权调用API流程,具体调用流程,请查看认证鉴权。
请求参数
Headers 参数
除公共头域外,无其它特殊头域
Body 参数
请求结构
POST /v2/app/chatflow/async/retrieve HTTP/1.1
HOST: qianfan.baidubce.com
Authorization: Bearer <API Key>
Content-Type: application/json
{
"execute_id": "bd880ce9-****-4bd2-ad12-bae0bfa0b9c6"
}
示例代码
curl
curl -X POST https://qianfan.baidubce.com/v2/app/chatflow/async/retrieve
-H "Authorization: Bearer bce-v3/ALTAK-******IGAQOuDwEyx1/cf9f5ccb6717264fc93bd3c713300542be00bc85"
-H "Content-Type: application/json"
-d '{
"execute_id": "bd880ce9-****-4bd2-ad12-bae0bfa0b9c6"
}'
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
response
oneOf {2}
多选一且必需“只能”符合其中一个
可选
显示子属性
隐藏子属性
response
object {10}
正确响应参数。
显示子属性
隐藏子属性
conversation_id
string
对话ID。
必选
message_id
string
一问或一答的标识ID。
必选
trace_id
string
正确响应ID。
必选
user_id
string
用户ID,用于计费依赖。
必选
end_user_id
string
终端用户ID。
可选
is_completion
string
异步工作流是否已经运行结束。
- true:运行结束
- false:未运行结束
必选
content
array
工作流的执行结果。
必选
显示子属性
隐藏子属性
items
object {3}
显示子属性
隐藏子属性
name
string
当前返回内容所对应的执行步骤名称。在异步执行场景下为“异步执行”。
必选
type
string
代表 event 类型。该字段的取值决定了 text 字段的内容结构。异步执行时固定为 "asynchronize"。
必选
text
object {2}
当前event元素内容。
必选
显示子属性
隐藏子属性
event
array
工作流执行过程中产生的事件序列。
必选
显示子属性
隐藏子属性
items
object {3}
显示子属性
隐藏子属性
type
string
事件类型。
必选
name
string
事件名称。
必选
text
object {0}
事件内容。
必选
显示子属性
隐藏子属性
暂无参数
node_results
array
各节点的执行结果详情。
必选
显示子属性
隐藏子属性
items
object {10}
显示子属性
隐藏子属性
node_id
string
节点ID。
必选
node_template_id
string
节点类型。
必选
node_name
string
节点名称。
必选
node_status
string
节点状态。
必选
inputs
object {0}
节点输入。
必选
显示子属性
隐藏子属性
暂无参数
outputs
object {0}
节点输出。
必选
显示子属性
隐藏子属性
暂无参数
node_execute_start_time
number
节点执行开始时间。
必选
node_execute_cost
number
节点执行耗时。
必选
input_tokens
integer
该节点消耗的输入token数。
必选
output_tokens
integer
该节点生成的输出token数。
必选
metrics
object {2}
必选
显示子属性
隐藏子属性
begin_time
string
工作流开始执行的UTC时间戳。
必选
duration
number
总执行耗时(秒)。
必选
usage
object {4}
token统计信息。
必选
显示子属性
隐藏子属性
prompt_tokens
integer
输入的 prompt token 数。
必选
completion_tokens
integer
模型生成的 token 数。
必选
total_tokens
integer
本次请求消耗的总 token 数量,包括输入和输出的数量。
必选
nodes
array
按节点拆分的 token 使用详情。
必选
显示子属性
隐藏子属性
items
object {2}
显示子属性
隐藏子属性
node_id
string
节点 ID。
必选
models_usage
array
该节点调用的大模型使用情况。
必选
显示子属性
隐藏子属性
items
object {4}
显示子属性
隐藏子属性
model_name
string
使用的模型名称。
必选
prompt_tokens
integer
该模型调用的输入 token 数。
必选
completion_tokens
integer
该模型调用的输出 token 数。
必选
total_tokens
integer
本次调用的总 token 数。
必选
event
object {7}
可选
显示子属性
隐藏子属性
id
string
运行事件ID。
可选
status
string
运行状态。
可选
name
string
工作流Agent名称。
可选
created_time
string
创建时间,符合UTC格式。
可选
error_code
string
错误码,成功响应时为空。
可选
error_code_int
integer
错误码(整数形式),0表示无错误。
可选
error_message
string
错误描述信息,成功响应时为空。
可选
response
object {3}
错误响应参数。
显示子属性
隐藏子属性
request_id
string
错误响应ID。
必选
code
string
错误代码,当发生异常时返回。
可选
message
string
错误消息,当发生异常时返回。
可选
json
{
"conversation_id": "bc3800ca-****-4dfb-9d84-3c931c89a218",
"message_id": "55e2e495-702e-****-9671-76602586a9ef",
"trace_id": "8bb60fb3-13c3-****-bb03-72dccd703b99",
"user_id": "47996032-9ed5-4a9c-****-0dc1409ec54f",
"is_completion": true,
"role": "tool",
"content": [
{
"type": "asynchronize",
"name": "异步执行",
"text": {
"event": [
{
"type": "message",
"name": "收集城市信息",
"text": {
"info": "请提供您要查询哪个城市的天气?"
}
},
{
"type": "interrupt",
"name": "收集城市信息",
"text": {
"id": "cc1da9f8-****-4e47-b88e-d043fbf0c2c6",
"type": "chat"
}
}
],
"node_results": [
{
"node_id": "9a73547****64835af9a24bb4d1b5b92",
"node_template_id": "start",
"node_name": "开始",
"node_status": "success",
"inputs": {},
"outputs": {},
"node_execute_start_time": 1766115667.4503715,
"node_execute_cost": 0.00014495849609375,
"input_tokens": 0,
"output_tokens": 0
},
{
"node_id": "8d84d1a****542ef93d578e4ae1fe0d7",
"node_template_id": "intention",
"node_name": "意图识别",
"node_status": "success",
"inputs": {
"query": "帮我查看北京今日天气情况"
},
"outputs": {
"thought": "用户需要查询的是北京今日的天气情况,这与查询城市天气的工具描述相匹配,因此选择查询城市天气工具。",
"classification": "查询城市天气",
"classificationID": 0
},
"node_execute_start_time": 1766115667.4519181,
"node_execute_cost": 3.4607999324798584,
"input_tokens": 400,
"output_tokens": 65
},
{
"node_id": "80d16a2b5****ec79711a67a732f35c9",
"node_template_id": "chat",
"node_name": "收集城市信息",
"node_status": "running",
"inputs": {
"city": "用户需要查询的是北京今日的天气情况,这与查询城市天气的工具描述相匹配,因此选择查询城市天气工具。"
},
"outputs": {},
"node_execute_start_time": 1766115670.914559,
"node_execute_cost": 0.03647565841674805,
"input_tokens": 0,
"output_tokens": 0
}
]
},
"metrics": {
"begin_time": "2025-12-19T11:41:07.325707",
"duration": 3.629
},
"usage": {
"prompt_tokens": 400,
"completion_tokens": 65,
"total_tokens": 465,
"nodes": [
{
"node_id": "8d84d1a429****ef93d578e4ae1fe0d7",
"models_usage": [
{
"model_name": "ernie-3.5-8k",
"prompt_tokens": 400,
"completion_tokens": 65,
"total_tokens": 465
}
]
}
]
},
"event": {
"id": "5e7108e68****43908eea33dd3bda22",
"status": "done",
"name": "旅行客服小助手",
"created_time": "2025-12-19T11:41:07.443213",
"error_code": "",
"error_code_int": 0,
"error_message": ""
}
}
]
}
json
{
"requestId": "a74bccae-f11b-4c6a-b054-49ad53878dd6",
"code": 216003,
"message": "Authentication error: ( Authorization or X-Appbuilder-Authorization header or api_key query is required )"
}
