Query analytics data
Changed onExecute an analytics query with specified metrics, dimensions, filters, and time range. Custom access requires an organization-scoped key with analytics:view; grouping or filtering by api_key_id or api_key_tag also requires api_keys:view_all, and by user requires org_members:view. Key hash filters resolve only non-deleted ordinary keys. Workspace-scoped keys with base Read Only or Read Write access can query only their own workspace: a workspace filter naming another workspace is refused, legacy rows with no workspace are excluded (including for the default workspace), and possible-cache metrics such as possible_cached_tokens return 400. Management key required.
Request
- Base URLhttps://openrouter.ai/api/v1
- AuthHTTP bearer
Request body
Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace.
Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions.
Time granularity
Maximum rows per distinct combination of dimensions. When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified.
Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations.
Example request
{
"classifier_dimensions": {
"classifier_id": "550e8400-e29b-41d4-a716-446655440000",
"dimension_names": [
"department"
]
},
"classifier_filters": {
"classifier_id": "550e8400-e29b-41d4-a716-446655440000",
"filters": [
{
"field": "department",
"operator": "eq"
}
]
},
"dimensions": [
"model"
],
"filters": [
{
"field": "model",
"operator": "eq"
}
],
"granularity": "day",
"group_limit": 100,
"metrics": [
"request_count"
],
"order_by": {
"field": "request_count"
},
"time_range": {
"end": "2027-12-31T23:59:59Z",
"start": "2027-12-31T23:59:59Z"
}
}Response
Analytics query results
Changes
- breaking
added the pattern
^[a-zA-Z_][a-zA-Z0-9_]{0,63}$to the request propertyclassifier_dimensions/dimension_names/items - breaking
the
classifier_filters/filters/itemsrequest property type changed fromobjectto no type - breaking
the
filters/itemsrequest property type changed fromobjectto no type
9 more changes in this revision
- breaking