Skip to main content
GET
Query usage records
Usage data is aggregated into whole UTC buckets (days by default, hours for ranges up to 30 days) and reflects metered volume — characters, tokens and audio seconds — not invoiced amounts. Data is complete up to readTime, roughly one hour behind real time: re-fetch recent windows rather than treating them as final. History is available for the last 30 days. int64 metric values are returned as JSON strings.

Authorizations

Authorization
string
header
required

Your authentication credentials. For Basic authentication, please populate Basic $INWORLD_API_KEY.

Query Parameters

startTime
string<date-time>
required

Range start, inclusive.

endTime
string<date-time>
required

Range end, exclusive.

granularity
enum<string>
default:GRANULARITY_DAY

Bucket size; defaults to GRANULARITY_DAY.

  • GRANULARITY_UNSPECIFIED: Unspecified; treated as GRANULARITY_DAY.
  • GRANULARITY_HOUR: Calendar hour in UTC. Supported for ranges up to 30 days; longer ranges are rejected with INVALID_ARGUMENT.
  • GRANULARITY_DAY: Default. Calendar day in UTC.
  • GRANULARITY_MONTH: Reserved; not offered in v1.
Available options:
GRANULARITY_UNSPECIFIED,
GRANULARITY_HOUR,
GRANULARITY_DAY,
GRANULARITY_MONTH
timeZone
string

IANA time zone for bucket boundaries. Not supported in v1 — buckets are always computed in UTC. Clients must leave this unset; servers reject non-empty values with INVALID_ARGUMENT.

groupBy
enum<string>[]

Dimensions to group by. Omitted: one row per time bucket, all models summed. USAGE_DIMENSION_API_KEY is filter-only in v1 — servers reject it here with INVALID_ARGUMENT.

  • USAGE_DIMENSION_UNSPECIFIED: Unspecified; invalid as a group_by value.
  • USAGE_DIMENSION_SERVICE: tts | llm | stt | ...
  • USAGE_DIMENSION_MODEL: e.g. tts-2.0. The v1 main path.
  • USAGE_DIMENSION_SERVICE_PROVIDER: Upstream inference provider.
  • USAGE_DIMENSION_API_KEY: Filter only in v1; group_by support later.
Available options:
USAGE_DIMENSION_UNSPECIFIED,
USAGE_DIMENSION_SERVICE,
USAGE_DIMENSION_MODEL,
USAGE_DIMENSION_SERVICE_PROVIDER,
USAGE_DIMENSION_API_KEY
services
string[]

Service filter (e.g. "tts"). Open strings; repeated values mean IN semantics — same for the other dimension filters below.

models
string[]

Model filter (e.g. "tts-2.0").

serviceProviders
string[]

Service-provider filter.

apiKeyIds
string[]

Same-workspace API-key filter. Rejected when the backing store cannot apply it faithfully (never silently ignored).

metrics
string[]

Metric selection (e.g. "characters", "input_tokens"). Empty means all consumption metrics for the requested services; never plan fees.

pageSize
integer<int32>

Maximum records per page; values above the server maximum are coerced.

pageToken
string

Opaque cursor from a previous response.

Response

A successful response.

Response for QueryUsageRecords.

usageRecords
object[]

Usage rows for the requested range: one per time bucket × dimension group.

nextPageToken
string

Empty when there are no further pages.

totalSize
integer<int32>
read-only

Omitted by default (expensive to compute per page); explicit presence so clients can tell "absent" from a real 0.

readTime
string<date-time>
read-only

Freshness watermark: the returned data is complete up to this time. Usage is not a live counter; clients should re-fetch recent windows rather than assume immutability.