API Reference - Events Ingestion
完整的 API 文档,包含示例和响应代码。
事件结构
Required Fields
Required Fields
Optional Fields
Optional Fields
发送事件
摄取蓝图
适用于常见用例的现成事件模式。使用经过验证的蓝图开始,而不是从头开始构建。LLM Blueprint
跟踪 OpenAI、Anthropic、Groq、Gemini 等平台的 AI 令牌使用情况。
API Gateway Blueprint
通过端点过滤和速率限制支持对 API 请求进行计量。
Object Storage Blueprint
跟踪云存储服务的文件上传和存储消耗情况。
Stream Blueprint
衡量视频、音频和实时数据的流式带宽。
Time Range Blueprint
按运行时间为无服务器函数和计算实例计费。
View All Blueprints
查看所有可用蓝图及详细实现指南。
最佳实践
Use Unique Event IDs
Use Unique Event IDs
使用确定性 ID 防止重复:
${customerId}_${action}_${timestamp}Implement Retries
Implement Retries
在遇到 5xx 错误时使用指数退避重试。不要对 4xx 错误重试。
Include Timestamps
Include Timestamps
实时事件可省略。对于延迟/批量事件请包含,以确保准确性。
Monitor Delivery
Monitor Delivery
跟踪成功率并将失败事件排队以便重试。
故障排除
Events not appearing
Events not appearing
- 事件名称必须与计量器完全匹配(区分大小写)
- 客户 ID 必须存在
- 检查计量器过滤器是否排除了事件
- 确认时间戳是最近的
Authentication errors (401)
Authentication errors (401)
验证 API 密钥是否正确并使用格式:
Bearer YOUR_API_KEYValidation errors (400)
Validation errors (400)
确保所有必填字段都已提供:
event_id、customer_id、event_nameMetadata not aggregating
Metadata not aggregating
- 元数据键必须与计量器的“Over Property”完全一致
- 使用数字,而非字符串:
tokens: 150,而不是tokens: "150"