Overview
beta.Analytics endpointsAvailable Operations
- get_analytics_meta - Get available analytics metrics and dimensions
- query_analytics - Query analytics data
get_analytics_meta
Returns the available metrics, dimensions, filter operators, and granularities for the analytics query endpoint. Management key required.Example Usage
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
http_referer | Optional[str] | :heavy_minus_sign: | The app identifier should be your app’s URL and is used as the primary identifier for rankings. This is used to track API usage per application. |
x_open_router_title | Optional[str] | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter’s dashboard. |
x_open_router_categories | Optional[str] | :heavy_minus_sign: | Comma-separated list of app categories (e.g. “cli-agent,cloud-agent”). Used for marketplace rankings. |
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
operations.GetAnalyticsMetaResponseErrors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |
query_analytics
Execute an analytics query with specified metrics, dimensions, filters, and time range. Management key required.Example Usage
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
metrics | List[str] | :heavy_check_mark: | N/A | |
http_referer | Optional[str] | :heavy_minus_sign: | The app identifier should be your app’s URL and is used as the primary identifier for rankings. This is used to track API usage per application. | |
x_open_router_title | Optional[str] | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter’s dashboard. | |
x_open_router_categories | Optional[str] | :heavy_minus_sign: | Comma-separated list of app categories (e.g. “cli-agent,cloud-agent”). Used for marketplace rankings. | |
dimensions | List[str] | :heavy_minus_sign: | N/A | |
filters | List[operations.Filter] | :heavy_minus_sign: | N/A | |
granularity | Optional[str] | :heavy_minus_sign: | Time granularity | day |
group_limit | Optional[int] | :heavy_minus_sign: | 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. | 100 |
limit | Optional[int] | :heavy_minus_sign: | 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. | |
order_by | Optional[operations.OrderBy] | :heavy_minus_sign: | N/A | |
time_range | Optional[operations.TimeRange] | :heavy_minus_sign: | N/A | |
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
operations.QueryAnalyticsResponseErrors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.RequestTimeoutResponseError | 408 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | */* |