Skip to content

API reference — Usage analytics

The usage analytics endpoint aggregates request data from the platform’s usage_records table. It supports configurable time bucketing (day/week/month), model filtering, and per-user cost rankings. Admin access is required.

Base path: GET /api/usage/analytics

Authentication: Authorization: Bearer arb_live_<admin-key>


The top-level response object.

FieldTypeDescription
time_seriesTimeSeriesPoint[]Time-bucketed usage data for the requested period
by_modelModelBreakdown[]Aggregated usage per model for the requested period
top_usersTopUser[]Users ranked by total cost (descending)

One entry per time bucket in the requested aggregation period.

FieldTypeDescription
periodstringPeriod label — "2026-03-12" (day), "2026-W11" (week), "2026-03" (month)
input_tokensintegerTotal input tokens processed in this period
output_tokensintegerTotal output tokens generated in this period
costfloatEstimated total cost (USD) in this period
request_countintegerNumber of AI requests in this period
FieldTypeDescription
model_idstringModel identifier
providerstringProvider name
input_tokensintegerTotal input tokens for this model
output_tokensintegerTotal output tokens for this model
costfloatTotal estimated cost (USD) for this model
request_countintegerNumber of requests to this model
FieldTypeDescription
user_idstringUser UUID
usernamestringUser display name
total_costfloatTotal cost attributed to this user (USD)
request_countintegerTotal requests by this user

GET /api/usage/analytics

Returns aggregated usage analytics for the admin dashboard. Admin role required.

Query parameters:

ParameterTypeDefaultDescription
date_fromdate (YYYY-MM-DD)Start date inclusive (optional)
date_todate (YYYY-MM-DD)End date inclusive (optional)
aggregationstringdayTime bucketing: day, week, or month
model_idstringFilter results to a specific model ID (optional)

Request — last 30 days, daily bucketing:

Terminal window
GET /api/usage/analytics?date_from=2026-02-11&date_to=2026-03-12&aggregation=day
Authorization: Bearer arb_live_your-admin-key

Response (200):

{
"time_series": [
{
"period": "2026-03-10",
"input_tokens": 4250000,
"output_tokens": 820000,
"cost": 18.42,
"request_count": 1240
},
{
"period": "2026-03-11",
"input_tokens": 5100000,
"output_tokens": 960000,
"cost": 22.18,
"request_count": 1480
},
{
"period": "2026-03-12",
"input_tokens": 2100000,
"output_tokens": 410000,
"cost": 9.32,
"request_count": 620
}
],
"by_model": [
{
"model_id": "claude-3-5-sonnet-20241022",
"provider": "anthropic",
"input_tokens": 8200000,
"output_tokens": 1540000,
"cost": 34.50,
"request_count": 2180
},
{
"model_id": "gpt-4o-mini",
"provider": "openai",
"input_tokens": 3250000,
"output_tokens": 650000,
"cost": 15.42,
"request_count": 1160
}
],
"top_users": [
{
"user_id": "7c8d9e0f-1234-5678-abcd-ef0123456789",
"username": "alice",
"total_cost": 14.20,
"request_count": 820
},
{
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"username": "bob",
"total_cost": 9.80,
"request_count": 560
}
]
}

Request — monthly aggregation for a specific model:

Terminal window
GET /api/usage/analytics?aggregation=month&model_id=claude-3-5-sonnet-20241022
Authorization: Bearer arb_live_your-admin-key

Error (403 Forbidden):

{ "detail": "Admin access required" }

Error (400 Bad Request):

{ "detail": "aggregation must be one of: day, week, month" }

AggregationPeriod label formatExample
dayYYYY-MM-DD2026-03-12
weekYYYY-WWW2026-W11
monthYYYY-MM2026-03

The week label uses ISO week numbering (%W — week 00 for days before the first Monday of the year). Use the date_from / date_to filters to bound the response to a meaningful range.


  • Cost values are estimates based on the cost_per_input_token and cost_per_output_token values in the model catalog. If these fields are null for a model, cost will be 0.0 for that model’s rows.
  • top_users always covers the full requested date range, regardless of aggregation. It is not time-bucketed.
  • Empty periods — dates with no requests are not included in time_series. Gaps in the series indicate zero-activity periods.
  • If neither date_from nor date_to is specified, the query covers all historical data. For large deployments, always provide date bounds to avoid slow queries.