import * as z from "zod/v4"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type QueryAnalyticsGlobals = { /** * The app identifier should be your app's URL and is used as the primary identifier for rankings. * * @remarks * This is used to track API usage per application. */ httpReferer?: string | undefined; /** * The app display name allows you to customize how your app appears in OpenRouter's dashboard. * * @remarks */ appTitle?: string | undefined; /** * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. * * @remarks */ appCategories?: string | undefined; }; /** * Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. */ export type ClassifierDimensions = { /** * UUID of the classifier whose tags to group by. */ classifierId: string; dimensionNames?: Array | undefined; /** * When true, also include generations that have no tag from this classifier. Defaults to false, which returns only classified generations. */ includeNulls?: boolean | undefined; }; export type ValueClassifierFilters = string | number; /** * Filter value. Use a scalar (string or number) for eq/neq, or an array for in/not_in. */ export type ClassifierFiltersValue = string | number | Array; export type ClassifierFiltersFilter = { /** * Classifier dimension name to filter on (snake_case identifier, e.g. "department", "work_type"). */ field: string; /** * Filter operator. Only equality/set operators are supported (eq, neq, in, not_in) — ordered comparisons are not available because classification values are strings. */ operator: string; /** * Filter value. Use a scalar (string or number) for eq/neq, or an array for in/not_in. */ value: string | number | Array; }; /** * 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. */ export type ClassifierFilters = { /** * UUID of the classifier whose tags to filter by. Must match classifier_dimensions.classifier_id when both are specified. */ classifierId: string; filters: Array; }; export type Value2 = string | number; /** * Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. "user_abc123"), not the display name; `workspace` — workspace UUID, not the workspace name (filtering or grouping by the account default workspace also covers activity recorded before workspace resolution existed, which is attributed to that default workspace); `app` — numeric app ID, not the app title; `model` — permaslug (e.g. "openai/gpt-4o"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned. */ export type Value1 = string | number | Array; export type Filter = { /** * Dimension to filter on. Use the /meta endpoint for available dimensions. */ field: string; /** * Include rows where the dimension has no value. Applies only to the `in` and `not_in` operators and dimensions that have an unset bucket. */ includeUnset?: boolean | undefined; /** * Filter operator */ operator: string; /** * Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. "user_abc123"), not the display name; `workspace` — workspace UUID, not the workspace name (filtering or grouping by the account default workspace also covers activity recorded before workspace resolution existed, which is attributed to that default workspace); `app` — numeric app ID, not the app title; `model` — permaslug (e.g. "openai/gpt-4o"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned. */ value: string | number | Array; }; export declare const Direction: { readonly Asc: "asc"; readonly Desc: "desc"; }; export type Direction = OpenEnum; export type OrderBy = { direction: Direction; /** * Field to order by: a metric included in `metrics` (or "request_count", which may be ordered by without being requested), a requested dimension, or "date". */ field: string; }; export type TimeRange = { /** * ISO 8601 UTC timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected. */ end: Date; /** * ISO 8601 UTC timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected. */ start: Date; }; export type QueryAnalyticsRequestBody = { /** * Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace. */ classifierDimensions?: ClassifierDimensions | undefined; /** * 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. */ classifierFilters?: ClassifierFilters | undefined; dimensions?: Array | undefined; filters?: Array | undefined; /** * Time granularity */ granularity?: string | undefined; /** * 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. */ groupLimit?: number | undefined; /** * 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. */ limit?: number | undefined; metrics: Array; orderBy?: OrderBy | undefined; timeRange?: TimeRange | undefined; }; export type QueryAnalyticsRequest = { /** * The app identifier should be your app's URL and is used as the primary identifier for rankings. * * @remarks * This is used to track API usage per application. */ httpReferer?: string | undefined; /** * The app display name allows you to customize how your app appears in OpenRouter's dashboard. * * @remarks */ appTitle?: string | undefined; /** * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. * * @remarks */ appCategories?: string | undefined; requestBody: QueryAnalyticsRequestBody; }; /** * A row of analytics data with metric/dimension values */ export type QueryAnalyticsData1 = {}; export type Metadata = { queryTimeMs: number; rowCount: number; truncated: boolean; }; export type QueryAnalyticsData2 = { cachedAt?: number | undefined; data: Array; metadata: Metadata; /** * Warnings about filter resolution issues (e.g. unresolvable api_key_id hashes). The query still runs normally; these inform the caller that some filter values could not be resolved. */ warnings?: Array | undefined; }; /** * Analytics query results */ export type QueryAnalyticsResponse = { data: QueryAnalyticsData2; }; /** @internal */ export type ClassifierDimensions$Outbound = { classifier_id: string; dimension_names?: Array | undefined; include_nulls?: boolean | undefined; }; /** @internal */ export declare const ClassifierDimensions$outboundSchema: z.ZodType; export declare function classifierDimensionsToJSON(classifierDimensions: ClassifierDimensions): string; /** @internal */ export type ValueClassifierFilters$Outbound = string | number; /** @internal */ export declare const ValueClassifierFilters$outboundSchema: z.ZodType; export declare function valueClassifierFiltersToJSON(valueClassifierFilters: ValueClassifierFilters): string; /** @internal */ export type ClassifierFiltersValue$Outbound = string | number | Array; /** @internal */ export declare const ClassifierFiltersValue$outboundSchema: z.ZodType; export declare function classifierFiltersValueToJSON(classifierFiltersValue: ClassifierFiltersValue): string; /** @internal */ export type ClassifierFiltersFilter$Outbound = { field: string; operator: string; value: string | number | Array; }; /** @internal */ export declare const ClassifierFiltersFilter$outboundSchema: z.ZodType; export declare function classifierFiltersFilterToJSON(classifierFiltersFilter: ClassifierFiltersFilter): string; /** @internal */ export type ClassifierFilters$Outbound = { classifier_id: string; filters: Array; }; /** @internal */ export declare const ClassifierFilters$outboundSchema: z.ZodType; export declare function classifierFiltersToJSON(classifierFilters: ClassifierFilters): string; /** @internal */ export type Value2$Outbound = string | number; /** @internal */ export declare const Value2$outboundSchema: z.ZodType; export declare function value2ToJSON(value2: Value2): string; /** @internal */ export type Value1$Outbound = string | number | Array; /** @internal */ export declare const Value1$outboundSchema: z.ZodType; export declare function value1ToJSON(value1: Value1): string; /** @internal */ export type Filter$Outbound = { field: string; include_unset?: boolean | undefined; operator: string; value: string | number | Array; }; /** @internal */ export declare const Filter$outboundSchema: z.ZodType; export declare function filterToJSON(filter: Filter): string; /** @internal */ export declare const Direction$outboundSchema: z.ZodType; /** @internal */ export type OrderBy$Outbound = { direction: string; field: string; }; /** @internal */ export declare const OrderBy$outboundSchema: z.ZodType; export declare function orderByToJSON(orderBy: OrderBy): string; /** @internal */ export type TimeRange$Outbound = { end: string; start: string; }; /** @internal */ export declare const TimeRange$outboundSchema: z.ZodType; export declare function timeRangeToJSON(timeRange: TimeRange): string; /** @internal */ export type QueryAnalyticsRequestBody$Outbound = { classifier_dimensions?: ClassifierDimensions$Outbound | undefined; classifier_filters?: ClassifierFilters$Outbound | undefined; dimensions?: Array | undefined; filters?: Array | undefined; granularity?: string | undefined; group_limit?: number | undefined; limit?: number | undefined; metrics: Array; order_by?: OrderBy$Outbound | undefined; time_range?: TimeRange$Outbound | undefined; }; /** @internal */ export declare const QueryAnalyticsRequestBody$outboundSchema: z.ZodType; export declare function queryAnalyticsRequestBodyToJSON(queryAnalyticsRequestBody: QueryAnalyticsRequestBody): string; /** @internal */ export type QueryAnalyticsRequest$Outbound = { "HTTP-Referer"?: string | undefined; appTitle?: string | undefined; appCategories?: string | undefined; RequestBody: QueryAnalyticsRequestBody$Outbound; }; /** @internal */ export declare const QueryAnalyticsRequest$outboundSchema: z.ZodType; export declare function queryAnalyticsRequestToJSON(queryAnalyticsRequest: QueryAnalyticsRequest): string; /** @internal */ export declare const QueryAnalyticsData1$inboundSchema: z.ZodType; export declare function queryAnalyticsData1FromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const Metadata$inboundSchema: z.ZodType; export declare function metadataFromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const QueryAnalyticsData2$inboundSchema: z.ZodType; export declare function queryAnalyticsData2FromJSON(jsonString: string): SafeParseResult; /** @internal */ export declare const QueryAnalyticsResponse$inboundSchema: z.ZodType; export declare function queryAnalyticsResponseFromJSON(jsonString: string): SafeParseResult; //# sourceMappingURL=queryanalytics.d.ts.map