直接在 OpenClaw 中调用 Coze Workflow API。
设置 PAT Key 环境变量:
export COZE_PAT_KEY="your_pat_token_here"
curl -s --location --request POST 'https://api.coze.com/v1/workflow/stream_run' \
--header "Authorization: Bearer $COZE_PAT_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"workflow_id": "your_workflow_id",
"parameters": {
"key": "value"
}
}' \
--max-time 120
curl -s --location --request POST 'https://api.coze.com/v1/workflow/stream_run' \
--header "Authorization: Bearer $COZE_PAT_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"workflow_id": "your_workflow_id",
"parameters": {
"key": "value"
}
}' \
--max-time 120 > /tmp/coze_result.txt
| 参数 | 位置 | 说明 |
|---|---|---|
| ------ | ------ | ------ |
workflow_id | data-raw | Coze Workflow ID |
parameters | data-raw | Workflow 输入参数 (JSON 对象) |
COZE_PAT_KEY | header | PAT Token,通过环境变量传入 |
export COZE_PAT_KEY="your_pat_token_here"
curl -s --location --request POST 'https://api.coze.com/v1/workflow/stream_run' \
--header "Authorization: Bearer $COZE_PAT_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"workflow_id": "7566546276516642834",
"parameters": {
"id": "1859150663345201",
"id_type": "creative"
}
}' \
--max-time 120
流式响应,每行一个事件:
id: 0
event: PING
data: {...}
id: 1
event: Message
data: {"content":"...","node_type":"End",...}
id: 2
event: Done
data: {"debug_url":"..."}
关键字段:
event: Message - 包含 workflow 执行结果event: Done - 执行完成node_type: End - 结束节点--max-time 120共 1 个版本