事件订阅允许您在 Cloudflare 账户中发生事件时接收消息。Cloudflare 产品(例如 KV、Workers AI、Workers)可以将结构化事件发布到队列,然后您可以使用 Workers 或 HTTP 拉取消费者来消费这些事件,以构建自定义工作流、集成或逻辑。
在批处理请求入队时触发。
示例:
{
"type": "cf.workersAi.model.batch.queued",
"source": {
"type": "workersAi.model",
"modelName": "@cf/baai/bge-base-en-v1.5"
},
"payload": {
"requestId": "req-12345678-90ab-cdef-1234-567890abcdef"
},
"metadata": {
"accountId": "f9f79265f388666de8122cfb508d7776",
"eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
"eventSchemaVersion": 1,
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}在批处理请求完成时触发。
示例:
{
"type": "cf.workersAi.model.batch.succeeded",
"source": {
"type": "workersAi.model",
"modelName": "@cf/baai/bge-base-en-v1.5"
},
"payload": {
"requestId": "req-12345678-90ab-cdef-1234-567890abcdef"
},
"metadata": {
"accountId": "f9f79265f388666de8122cfb508d7776",
"eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
"eventSchemaVersion": 1,
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}在批处理请求失败时触发。
示例:
{
"type": "cf.workersAi.model.batch.failed",
"source": {
"type": "workersAi.model",
"modelName": "@cf/baai/bge-base-en-v1.5"
},
"payload": {
"requestId": "req-12345678-90ab-cdef-1234-567890abcdef",
"message": "Model execution failed",
"internalCode": 5001,
"httpCode": 500
},
"metadata": {
"accountId": "f9f79265f388666de8122cfb508d7776",
"eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
"eventSchemaVersion": 1,
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}