Request Logs
Overview
Section titled “Overview”The request logs endpoint returns a paginated list of recent requests handled by the gateway. Useful for debugging, auditing, and monitoring individual calls.
Endpoint: GET /v1/requests
Authentication: Required
Query Parameters
Section titled “Query Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 50 | Number of entries to return (max 500) |
offset | number | 0 | Number of entries to skip for pagination |
project_id | string | — | Filter results to a specific project |
Request
Section titled “Request”GET https://your-gateway.workers.dev/v1/requests?limit=20&offset=0Authorization: Bearer <your-token>Response
Section titled “Response”{ "total": 14823, "limit": 20, "offset": 0, "data": [ { "id": "req_01j9xkz3p4q5r6s7t8u9v0w1", "timestamp": "2024-11-15T10:32:45.123Z", "model": "gpt-4o", "provider": "openai", "status": 200, "latency_ms": 843, "input_tokens": 512, "output_tokens": 128, "project_id": "proj_abc123", "error": null }, { "id": "req_01j9xky2m3n4o5p6q7r8s9t0", "timestamp": "2024-11-15T10:31:12.044Z", "model": "claude-3-5-sonnet-20241022", "provider": "anthropic", "status": 429, "latency_ms": 210, "input_tokens": null, "output_tokens": null, "project_id": "proj_abc123", "error": "rate_limit_error" } ]}Log Entry Fields
Section titled “Log Entry Fields”| Field | Type | Description |
|---|---|---|
id | string | Unique request identifier |
timestamp | string | ISO 8601 UTC timestamp of when the request was received |
model | string | Model that was requested |
provider | string | Backend provider that served the request |
status | number | HTTP status code of the response |
latency_ms | number | End-to-end latency in milliseconds |
input_tokens | number | null | Input token count (null if unavailable or errored) |
output_tokens | number | null | Output token count (null if unavailable or errored) |
project_id | string | null | Project the request was attributed to |
error | string | null | Error type if the request failed, otherwise null |
Examples
Section titled “Examples”# Fetch the 20 most recent requestscurl "https://your-gateway.workers.dev/v1/requests?limit=20&offset=0" \ -H "Authorization: Bearer <your-token>"
# Filter by projectcurl "https://your-gateway.workers.dev/v1/requests?project_id=proj_abc123&limit=50" \ -H "Authorization: Bearer <your-token>"async function getRequestLogs({ limit = 50, offset = 0, projectId } = {}) { const params = new URLSearchParams({ limit, offset }); if (projectId) params.set('project_id', projectId);
const response = await fetch( `https://your-gateway.workers.dev/v1/requests?${params}`, { headers: { 'Authorization': 'Bearer <your-token>', }, } );
return response.json();}
// Fetch first pageconst logs = await getRequestLogs({ limit: 20 });console.log(`Showing ${logs.data.length} of ${logs.total} requests`);
// Paginateconst page2 = await getRequestLogs({ limit: 20, offset: 20 });