Purpose¶
Export aggregated time series for cost, errors, latency, and tokens over a selectable range.
Auth¶
- Bearer auth;
lib/auth.tscurrently mocks in dev mode (RUNFORGE_DEV_MODE=1).
Query¶
range=24h|7d|30d(default7d)projectId=<id>(optional; required when auth cannot infer project)aggregate=1|true(optional; aggregate across all projects)
Response¶
{
"points": [
{ "t": "2025-01-01T01:00:00.000Z", "costUSD": 0.12345, "errorRate": 0.01, "p95LatencyMs": 850, "runs": 42, "tokensIn": 1200, "tokensOut": 800 }
],
"costByProvider": { "openai": 1.23, "openrouter": 0.45 },
"costByModel": { "gpt-4o-mini": 0.67 },
"series": [
{ "t": "2025-01-01T01:00:00.000Z", "costUSD": 0.12345, "errorRate": 0.01, "p95LatencyMs": 850 }
]
}
Notes¶
- Uses Prisma to read
Runrows; requiresDATABASE_URL. seriesis a legacy shape; preferpoints.
See also: ../07-backend.md
Metrics API¶
GET /api/metrics
- Auth: Bearer project key
- Query params:
range=24h|7d|30d(default7d)projectId=<id>(optional)aggregate=1|true(optional)
Response example:
{
"points": [
{ "t": "2025-01-01T01:00:00.000Z", "costUSD": 0.12345, "errorRate": 0.01, "p95LatencyMs": 850, "runs": 42, "tokensIn": 1200, "tokensOut": 800 }
],
"costByProvider": { "openai": 1.23, "openrouter": 0.45 },
"costByModel": { "gpt-4o-mini": 0.67 },
"series": [
{ "t": "2025-01-01T01:00:00.000Z", "costUSD": 0.12345, "errorRate": 0.01, "p95LatencyMs": 850 }
]
}