工作流运行
执行工作流
适用于:Workflow。
执行工作流。没有已发布的工作流时无法执行。
POST
/
workflows
/
run
curl --request POST \
--url https://{api_base_url}/workflows/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"inputs": {
"query": "Summarize this text: The quick brown fox jumps over the lazy dog."
},
"response_mode": "streaming",
"user": "user_workflow_123"
}
'{
"task_id": "c3800678-a077-43df-a102-53f23ed20b88",
"workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156",
"data": {
"id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156",
"workflow_id": "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345",
"status": "succeeded",
"outputs": {
"result": "Bonjour le monde"
},
"error": null,
"elapsed_time": 1.23,
"total_tokens": 150,
"total_steps": 3,
"created_at": 1705407629,
"finished_at": 1705407630
}
}Authorizations
API Key 认证。对于所有 API 请求,请在 Authorization HTTP 头中包含您的 API Key,并加上 Bearer 前缀。示例:Authorization: Bearer {API_KEY}。强烈建议将 API Key 存储在服务端,不要在客户端共享或存储,以避免 API Key 泄漏导致严重后果。缺少或无效的 API Key 会返回 HTTP 401,错误码为 unauthorized。
Body
application/json
用户标识符,由开发者自定义规则,在应用内必须唯一。此标识符用于限定数据访问范围——工作流运行和文件仅在使用相同的 user 值查询时可见。
响应模式。使用 blocking 获取同步响应(Cloudflare 超时时间为 100 s),使用 streaming 获取服务器发送事件。未指定时默认为阻塞模式。
Available options:
streaming, blocking Response
请求成功。内容类型和结构取决于请求中的 response_mode 参数。
- 如果
response_mode为blocking,返回application/json和WorkflowBlockingResponse对象。 - 如果
response_mode为streaming,返回text/event-stream和ChunkWorkflowEvent对象流。
Last modified on July 9, 2026
Was this page helpful?
⌘I
curl --request POST \
--url https://{api_base_url}/workflows/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"inputs": {
"query": "Summarize this text: The quick brown fox jumps over the lazy dog."
},
"response_mode": "streaming",
"user": "user_workflow_123"
}
'{
"task_id": "c3800678-a077-43df-a102-53f23ed20b88",
"workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156",
"data": {
"id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156",
"workflow_id": "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345",
"status": "succeeded",
"outputs": {
"result": "Bonjour le monde"
},
"error": null,
"elapsed_time": 1.23,
"total_tokens": 150,
"total_steps": 3,
"created_at": 1705407629,
"finished_at": 1705407630
}
}