Skip to content

Analytics

The analytics endpoint returns aggregated usage statistics for your gateway — request volume, success/failure rates, and breakdowns by provider, model, project, and day. Aggregates are stored in Cloudflare D1. It exposes operational load data, so all requests require a valid GATEWAY_API_KEY Bearer token; without one the gateway returns 401.

Endpoint: GET /v1/analytics

Authentication: Required (GATEWAY_API_KEY)

GET https://your-gateway.workers.dev/v1/analytics?project_id=proj_abc123
Authorization: Bearer <GATEWAY_API_KEY>

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | project_id | string | No | Filter analytics to a single project. Omit for all-project totals. | | days | number | No | Restrict to the last N days (1–365). Omit for all time. |

{
"total_requests": 14823,
"successful_requests": 14201,
"failed_requests": 622,
"success_rate": 0.958,
"providers": {
"openai": {
"requests": 6400,
"successful": 6350,
"failed": 50
},
"anthropic": {
"requests": 5200,
"successful": 4980,
"failed": 220
}
},
"models": {
"gpt-4o": {
"requests": 3100,
"successful": 3080,
"failed": 20
}
}
}

| Field | Type | Description | |-------|------|-------------| | total_requests | number | Total number of requests handled by the gateway for this project | | successful_requests | number | Requests that returned a 2xx response | | failed_requests | number | Requests that returned a non-2xx response | | success_rate | number | Ratio of successful to total requests (0–1) | | providers | object | Per-provider breakdown of request counts | | models | object | Per-model breakdown of request counts |

Terminal window
curl "https://your-gateway.workers.dev/v1/analytics?project_id=proj_abc123" \
-H "Authorization: Bearer <GATEWAY_API_KEY>"