你的 AI Gateway 仪表板显示请求、token、缓存、错误和费用的指标。你可以按时间过滤这些指标。 这些分析帮助你了解流量模式、token 消耗以及 各 AI 提供商的潜在问题。你可以 查看以下分析:
- Requests(请求):跟踪 AI Gateway 处理的请求总数。
- Token Usage(Token 用量):分析请求中的 token 消耗,洞察使用模式。
- Costs(费用):了解使用不同 AI 提供商相关的费用,便于跟踪支出、管理预算和优化资源。
- Errors(错误):监控 gateway 中的错误数量,帮助识别和排查问题。
- Cached Responses(缓存响应):查看从缓存提供的响应百分比,有助于降低成本并提高速度。
要在仪表板中查看分析数据:
- 登录 Cloudflare 仪表板 ↗ 并选择你的账户。
- 前往 AI > AI Gateway。
- 确保已选择你的 gateway(网关)。
你可以使用 GraphQL 在 AI Gateway 仪表板之外查询使用数据。参见下方示例查询。发起请求时需要使用你的 Cloudflare 令牌,并将 {account_id} 更改为匹配你的账户标签。
curl https://api.cloudflare.com/client/v4/graphql \
--header 'Authorization: Bearer TOKEN \
--header 'Content-Type: application/json' \
--data '{
"query": "query{\n viewer {\n accounts(filter: { accountTag: \"{account_id}\" }) {\n requests: aiGatewayRequestsAdaptiveGroups(\n limit: $limit\n filter: { datetimeHour_geq: $start, datetimeHour_leq: $end }\n orderBy: [datetimeMinute_ASC]\n ) {\n count,\n dimensions {\n model,\n provider,\n gateway,\n ts: datetimeMinute\n }\n \n }\n \n }\n }\n}",
"variables": {
"limit": 1000,
"start": "2023-09-01T10:00:00.000Z",
"end": "2023-09-30T10:00:00.000Z",
"orderBy": "date_ASC"
}
}'