Get a usage time series
/v1/analytics/timeseriesGet a usage time series.
Returns one metric per time bucket over the requests matching the filters. Buckets are aligned to tz (local midnight for day) and every bucket in the window is returned, an empty one as 0. The window runs from start_time (default: the first retained log) to end_time (default now); it may hold at most 5000 buckets. With split_by=model, series also holds one series per model for the series_limit models with the most requests, plus one other series for the rest.
With workspace_id, requires access to that workspace: an organization owner or admin, a member of the workspace, an organization-scoped va_ key with the admin role, or a va_ key scoped to the workspace. Without it, requires an organization owner or admin, or an organization-scoped va_ key with the admin role. Fails with 400 for an unknown metric, granularity, time zone or split_by, a date-time without an offset, or a window of more than 5000 buckets.
Authorization
AuthorizationBearer va_A platform API key (
va_...), created under Settings > API keys. Scoped to an organization or one workspace, with an admin or member role. Used by the management API.
Query parameters
metricstringrequiredwhat to chart per bucket:
requests,tokens,cost(USD),cost_saved(USD saved by cache hits),latency(average duration in milliseconds),error_rateorcache_hit_rate(each 0 to 1)granularitystringthe bucket size:
hour,day(default) orweektzstringthe IANA time zone buckets are aligned to, e.g.
America/Toronto; default UTC. Fixed offsets such as+05:30are refusedstart_timestringstart of the window, inclusive (ISO 8601 date-time with offset)
end_timestringend of the window, exclusive (ISO 8601 date-time with offset)
organizationstringthe organization's slug
workspace_idstring<uuid>only this workspace's requests (UUID)
providerstringonly requests to this provider, as stored: upper case with underscores, e.g.
OPENAImodelstringonly requests for this model id
split_bystringmodelto add a series per model; omit for the total onlyseries_limitinteger<int32>with
split_by=model, how many models get their own series: default 6, 1 to 10
Responses
metricstringThe metric charted, as requested.
granularitystringThe bucket size:
hour,dayorweek.pointsobject[]The metric per bucket, oldest first, over every request matching the filters. Empty buckets are included as 0.
Child attributes
timestampstring<date-time>The start of the bucket (ISO 8601 date-time).
valuenumber<double>The metric's value in the bucket; 0 for a bucket with no requests.
seriesobject[]With
split_by=model: one series per model for the models with the most requests, then oneotherseries for every other model. Absent otherwise.Child attributes
namestringThe model id; null for the
otherseries.otherbooleanTrue for the series that sums every model without a series of its own.
pointsobject[]The metric per bucket for this model, on the same buckets as the total.
Child attributes
timestampstring<date-time>The start of the bucket (ISO 8601 date-time).
valuenumber<double>The metric's value in the bucket; 0 for a bucket with no requests.