---
title: "Query usage events"
method: POST
path: "/v1/ai-cost-management/events/query"
tags: ["usage-events"]
---

# Query usage events

`POST /v1/ai-cost-management/events/query`

## Request

- Base URL: `https://global.api.konghq.com`
- URL: `https://global.api.konghq.com/v1/ai-cost-management/events/query`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Returns totals over the organization's usage events in a time range, grouped by up to 2 dimensions and optionally split into calendar buckets. Groups come largest `reported_cost` first unless the request sets `sort`. For a caller whose access covers only particular principals or groups, the operation reads only the events of those principals and groups.

The operation doesn't change anything; the query goes in the body because it can be large. Each page holds `page.size` groups with their complete `series`. To read the next or previous page, a client sends the response's `meta.page.next` or `meta.page.previous` cursor back as `page.after` or `page.before` in an otherwise identical body.

The totals come from the same stored events as the usage event list and budget balances, so a query and a budget balance over the same scope and range report the same numbers. A redelivered copy of an event counts in the totals until it is merged into the stored event, so for a short time the totals can exceed the usage event list.

## Request body

- object
  - `starts_at` string, date-time, required: The start of the time range, as an RFC 3339 timestamp. Events whose `time` is at or after `starts_at` count.
  - `ends_at` string, date-time, required: The end of the time range, as an RFC 3339 timestamp after `starts_at`. Events whose `time` is before `ends_at` count.
  - `granularity` 'PT1H' | 'P1D' | 'P1W' | 'P1M': Splits each group's totals into time buckets of this calendar interval, returned in `series`: - `PT1H`: an hour. - `P1D`: a day. - `P1W`: an ISO week, starting on Monday. - `P1M`: a calendar month. Bucket boundaries follow the calendar in `time_zone`, so the first and last buckets can extend beyond `starts_at` and `ends_at`. The range can span at most 400 buckets. Without `granularity`, each group has only its totals for the whole range, and `series` is empty.
  - `time_zone` string, iana-time-zone: The IANA time zone whose calendar sets the bucket boundaries. The name must be spelled as the time zone database spells it, such as `Europe/Budapest`, not `europe/budapest`. Offsets such as `+02:00` aren't accepted. Defaults to `UTC`.
  - `dimensions` string[]: The dimensions to group the events by. Each group gets its own totals. An event without a value for a dimension goes into that dimension's `null` group, so unattributed usage is the `null` group of `subject`. With `group` or `team`, an event counts fully under each of its groups or teams, so their totals can add up to more than the events' overall total. Without `dimensions`, the response has a single group. At most 2 dimensions, each named once, from `subject`, `subject_id`, `subject_type`, `provider`, `model`, `model_id`, `request_mode`, `region`, `client`, `source`, `group`, `team`, `service_id`, `route_id`, `consumer_id`, `application_id`, `tags.<key>`. `tags.<key>` groups by the value of one tag.
  - `measures` string[]: The totals to compute for each group and bucket. At least 1 measure, each named once. Defaults to every measure except `subjects`. `subjects` counts the distinct non-empty subjects in each group. It needs a request without `granularity`, in `measures` and in `sort`. It isn't additive across groups: a subject whose events fall in two groups counts once in each.
  - `filters` object: Narrows the events to aggregate. Each key names a field, its value is a filter object, and all the filters must match. A filter object carries exactly one operator: - String fields take `eq`, `neq`, `in`, `nin`, `contains`, `ncontains`, `exists`, `and`, and `or`. - Gateway ID fields take `eq`, `neq`, `in`, `nin`, `exists`, `and`, and `or`. - `groups`, `teams`, and `consumer_group_ids` take `has`, `has_any`, `nhas`, `nhas_any`, `exists`, `and`, and `or`. A key of the form `tags.<key>` filters on the value of that tag, and each value it compares has at most 256 characters, none of them a control character. Group filters compare complete group references, `principal/{uuid}`, `consumer_group/{uuid}`, or `oidc/{group}`, and an OIDC group must match in text and case. Team filters compare complete team references, `principal/{uuid}`. `eq`, `neq`, `in`, and `nin` compare strings case-sensitively, and `contains` and `ncontains` ignore case. Gateway IDs compare case-insensitively. `time`, `reported_cost`, and `tokens` can't be filtered here, and `starts_at` and `ends_at` set the time range instead. A key that names one of them, or an unknown field, isn't accepted.
    - `source` AICostStringFilter: Filters on the event's `source`, which identifies the producer: a gateway's control plane, as `//control-planes/{uuid}`, or the principal that reported the event, as `//principals/{uuid}`.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `subject_type` AICostStringFilter: Filters on the type of the event's subject: `principal`, `consumer`, or `oidc`.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `subject` AICostStringFilter: Filters on the event's subject, the actor accountable for the usage, as a subject reference: `principal/{uuid}`, `consumer/{uuid}`, or `oidc/{sub}`. Unattributed usage has no subject, so `{ "exists": false }` selects it.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `subject_id` AICostStringFilter: Filters on the subject's identifier, the part of the subject reference after the `/`. The type isn't compared, so one value matches that identifier under every subject type.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `request_mode` AICostStringFilter: Filters on the request mode: `stream`, `oneshot`, or `realtime`.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `provider` AICostStringFilter: Filters on the provider that served the invocation.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `model` AICostStringFilter: Filters on the model that served the invocation, as the provider reports it.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `model_id` AICostStringFilter: Filters on the producer's stable identifier for the model in its model registry.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `region` AICostStringFilter: Filters on the provider's region, not the region of the gateway data plane.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `client` AICostStringFilter: Filters on the tool that made the call, as a normalized identifier such as `claude_code`.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `service_id` AICostUuidFilter: Filters on the gateway service's ID.
      - `eq` string, uuid: Matches a value equal to this UUID. The comparison ignores case.
      - `neq` string, uuid: Matches a value other than this UUID, or no value. The comparison ignores case.
      - `in` string[]: Matches a value equal to any of these UUIDs. The comparison ignores case. 1 to 100 UUIDs.
      - `nin` string[]: Matches a value equal to none of these UUIDs, or no value. The comparison ignores case. 1 to 100 UUIDs.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostUuidFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostUuidFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `route_id` AICostUuidFilter: Filters on the gateway route's ID.
      - `eq` string, uuid: Matches a value equal to this UUID. The comparison ignores case.
      - `neq` string, uuid: Matches a value other than this UUID, or no value. The comparison ignores case.
      - `in` string[]: Matches a value equal to any of these UUIDs. The comparison ignores case. 1 to 100 UUIDs.
      - `nin` string[]: Matches a value equal to none of these UUIDs, or no value. The comparison ignores case. 1 to 100 UUIDs.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostUuidFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostUuidFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `consumer_id` AICostUuidFilter: Filters on the gateway consumer's ID.
      - `eq` string, uuid: Matches a value equal to this UUID. The comparison ignores case.
      - `neq` string, uuid: Matches a value other than this UUID, or no value. The comparison ignores case.
      - `in` string[]: Matches a value equal to any of these UUIDs. The comparison ignores case. 1 to 100 UUIDs.
      - `nin` string[]: Matches a value equal to none of these UUIDs, or no value. The comparison ignores case. 1 to 100 UUIDs.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostUuidFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostUuidFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `consumer_group_ids` AICostUuidListFilter: Filters on the IDs of the event's gateway consumer groups.
      - `has` string, uuid: Matches when the list contains this value.
      - `has_any` string[]: Matches when the list contains any of these values. 1 to 100 values.
      - `nhas` string, uuid: Matches when the list doesn't contain this value, including an empty list.
      - `nhas_any` string[]: Matches when the list contains none of these values, including an empty list. 1 to 100 values.
      - `exists` boolean: `true` matches a list with at least one value, and `false` matches an empty or missing list.
      - `and` AICostUuidListFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostUuidListFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `groups` AICostGroupListFilter: Filters on the event's groups, as the producer supplied them. Values are complete group references, `principal/{uuid}`, `consumer_group/{uuid}`, or `oidc/{group}`, and an OIDC group must match in text and case.
      - `has` string: Matches when the list contains this value.
      - `has_any` string[]: Matches when the list contains any of these values. 1 to 100 values.
      - `nhas` string: Matches when the list doesn't contain this value, including an empty list.
      - `nhas_any` string[]: Matches when the list contains none of these values, including an empty list. 1 to 100 values.
      - `exists` boolean: `true` matches a list with at least one value, and `false` matches an empty or missing list.
      - `and` AICostGroupListFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostGroupListFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `teams` AICostTeamListFilter: Filters on the event's Kong Identity teams, as the producer supplied them. Values are complete team references, `principal/{uuid}`.
      - `has` string: Matches when the list contains this value.
      - `has_any` string[]: Matches when the list contains any of these values. 1 to 100 values.
      - `nhas` string: Matches when the list doesn't contain this value, including an empty list.
      - `nhas_any` string[]: Matches when the list contains none of these values, including an empty list. 1 to 100 values.
      - `exists` boolean: `true` matches a list with at least one value, and `false` matches an empty or missing list.
      - `and` AICostTeamListFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostTeamListFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `application_id` AICostUuidFilter: Filters on the gateway application's ID.
      - `eq` string, uuid: Matches a value equal to this UUID. The comparison ignores case.
      - `neq` string, uuid: Matches a value other than this UUID, or no value. The comparison ignores case.
      - `in` string[]: Matches a value equal to any of these UUIDs. The comparison ignores case. 1 to 100 UUIDs.
      - `nin` string[]: Matches a value equal to none of these UUIDs, or no value. The comparison ignores case. 1 to 100 UUIDs.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostUuidFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostUuidFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
    - `arrival` AICostStringFilter: Filters on whether the event arrived late: `late` when it reached the service more than 1 hour after its `time`, and `on_time` otherwise.
      - `eq` string: Matches a value equal to this one. The comparison is case-sensitive.
      - `neq` string: Matches a value other than this one, or no value. The comparison is case-sensitive.
      - `in` string[]: Matches a value equal to any of these. The comparison is case-sensitive. 1 to 100 values.
      - `nin` string[]: Matches a value equal to none of these, or no value. The comparison is case-sensitive. 1 to 100 values.
      - `contains` string: Matches a value that contains this text. The comparison ignores case.
      - `ncontains` string: Matches a value that doesn't contain this text, or no value. The comparison ignores case.
      - `exists` boolean: `true` matches a field that has a value, and `false` matches a field without one.
      - `and` AICostStringFilter[]: Matches when every nested filter matches. 1 to 10 filters.
      - `or` AICostStringFilter[]: Matches when at least one nested filter matches. 1 to 10 filters.
  - `sort` object[]: The order of the groups, as sort keys in priority order. A key names a measure, which sorts the groups by their total over the whole range, or a requested dimension. The service adds the requested dimensions, ascending, as tiebreakers so the order is unique, and `null` dimension values sort last. At least 1 key, each naming a different field. Defaults to `reported_cost` in `desc` order.
    - `field` string, required: The measure or requested dimension to sort by. A measure sorts the groups by their total over the whole range.
    - `direction` 'asc' | 'desc': `asc` for ascending or `desc` for descending order. Defaults to `asc`.
  - `page` object: Selects a page of groups and its size. A request can't set both `after` and `before`, and a cursor that doesn't match the request's `sort` isn't accepted.
    - `size` integer: The number of groups on each page. 1 to 100. Defaults to `20`.
    - `after` string: A cursor for the page after an earlier response's page. Clients take it from that response's `meta.page.next` and don't build or change it. The rest of the body must stay the same.
    - `before` string: A cursor for the page before an earlier response's page. Clients take it from that response's `meta.page.previous` and don't build or change it. The rest of the body must stay the same.

## Response `200`

A page of groups with their totals.

- object
  - `data` object[], required: The groups on this page, in `sort` order.
    - `dimensions` object, required: The group's value for each requested dimension. A value is `null` when the group's events have no value for that dimension. The object is empty when the request names no dimensions.
    - `measures` object, required: The totals of the requested measures. `reported_cost` and `reported_cache_cost` are money objects, and every other measure is a decimal string. Only the requested measures appear.
      - `events` string: The number of events. Each event is one invocation.
      - `unpriced_events` string: The number of unpriced events: events that report a positive quantity of a token kind other than `reported_total_tokens`, but whose stored `reported_cost` is zero.
      - `reported_cost` AICostMoney: The events' total `reported_cost`. An event without a reported cost counts as zero.
        - `value` string, required: The amount in major units of `currency`, as a canonical decimal string such as `4125.5` or `0.004372`: at most 9 fractional digits, no trailing fractional zeros, no exponent, and a leading `-` only when the amount is negative.
        - `currency` 'USD', required: The currency of `value`.
      - `reported_cache_cost` AICostMoney: The events' total `reported_cache_cost`, the part of the cost for cache reads and cache writes. An event without one counts as zero.
        - `value` string, required: The amount in major units of `currency`, as a canonical decimal string such as `4125.5` or `0.004372`: at most 9 fractional digits, no trailing fractional zeros, no exponent, and a leading `-` only when the amount is negative.
        - `currency` 'USD', required: The currency of `value`.
      - `input_tokens` string: The sum of the events' `input_tokens` quantities.
      - `input_text_tokens` string: The sum of the events' `input_text_tokens` quantities.
      - `input_audio_tokens` string: The sum of the events' `input_audio_tokens` quantities.
      - `input_image_tokens` string: The sum of the events' `input_image_tokens` quantities.
      - `input_cache_read_tokens` string: The sum of the events' `input_cache_read_tokens` quantities.
      - `input_cache_read_text_tokens` string: The sum of the events' `input_cache_read_text_tokens` quantities.
      - `input_cache_read_audio_tokens` string: The sum of the events' `input_cache_read_audio_tokens` quantities.
      - `input_cache_read_image_tokens` string: The sum of the events' `input_cache_read_image_tokens` quantities.
      - `input_cache_read_video_tokens` string: The sum of the events' `input_cache_read_video_tokens` quantities.
      - `input_cache_write_tokens` string: The sum of the events' `input_cache_write_tokens` quantities.
      - `input_cache_write_text_tokens` string: The sum of the events' `input_cache_write_text_tokens` quantities.
      - `input_cache_write_audio_tokens` string: The sum of the events' `input_cache_write_audio_tokens` quantities.
      - `input_cache_write_image_tokens` string: The sum of the events' `input_cache_write_image_tokens` quantities.
      - `input_cache_write_video_tokens` string: The sum of the events' `input_cache_write_video_tokens` quantities.
      - `output_tokens` string: The sum of the events' `output_tokens` quantities.
      - `output_text_tokens` string: The sum of the events' `output_text_tokens` quantities.
      - `output_audio_tokens` string: The sum of the events' `output_audio_tokens` quantities.
      - `output_reasoning_tokens` string: The sum of the events' `output_reasoning_tokens` quantities.
      - `accepted_prediction_tokens` string: The sum of the events' `accepted_prediction_tokens` quantities.
      - `rejected_prediction_tokens` string: The sum of the events' `rejected_prediction_tokens` quantities.
      - `realtime_audio_ms` string: The sum of the events' `realtime_audio_ms` quantities.
      - `reported_total_tokens` string: The sum of the events' `reported_total_tokens` quantities.
      - `total_input_tokens` string: The events' total input, cached or not: the sum of `input_tokens`, `input_cache_read_tokens`, and `input_cache_write_tokens`. A missing quantity counts as zero, and modality detail quantities aren't added.
      - `subjects` string: The number of distinct subjects among the events. Unattributed events don't count. A subject whose events fall in several groups counts once in each, so the groups' counts can add up to more than the overall count. Only a request without `granularity` can name it.
    - `series` object[], required: With `granularity`, the group's totals for each bucket, oldest first. Only buckets that contain events appear. Without `granularity`, the list is empty.
      - `starts_at` string, date-time, required: The start of the bucket, as an RFC 3339 timestamp in UTC.
      - `ends_at` string, date-time, required: The end of the bucket, as an RFC 3339 timestamp in UTC. The bucket ends just before this time.
      - `measures` object, required: The totals of the requested measures. `reported_cost` and `reported_cache_cost` are money objects, and every other measure is a decimal string. Only the requested measures appear.
        - `events` string: The number of events. Each event is one invocation.
        - `unpriced_events` string: The number of unpriced events: events that report a positive quantity of a token kind other than `reported_total_tokens`, but whose stored `reported_cost` is zero.
        - `reported_cost` AICostMoney: The events' total `reported_cost`. An event without a reported cost counts as zero.
          - `value` string, required: The amount in major units of `currency`, as a canonical decimal string such as `4125.5` or `0.004372`: at most 9 fractional digits, no trailing fractional zeros, no exponent, and a leading `-` only when the amount is negative.
          - `currency` 'USD', required: The currency of `value`.
        - `reported_cache_cost` AICostMoney: The events' total `reported_cache_cost`, the part of the cost for cache reads and cache writes. An event without one counts as zero.
          - `value` string, required: The amount in major units of `currency`, as a canonical decimal string such as `4125.5` or `0.004372`: at most 9 fractional digits, no trailing fractional zeros, no exponent, and a leading `-` only when the amount is negative.
          - `currency` 'USD', required: The currency of `value`.
        - `input_tokens` string: The sum of the events' `input_tokens` quantities.
        - `input_text_tokens` string: The sum of the events' `input_text_tokens` quantities.
        - `input_audio_tokens` string: The sum of the events' `input_audio_tokens` quantities.
        - `input_image_tokens` string: The sum of the events' `input_image_tokens` quantities.
        - `input_cache_read_tokens` string: The sum of the events' `input_cache_read_tokens` quantities.
        - `input_cache_read_text_tokens` string: The sum of the events' `input_cache_read_text_tokens` quantities.
        - `input_cache_read_audio_tokens` string: The sum of the events' `input_cache_read_audio_tokens` quantities.
        - `input_cache_read_image_tokens` string: The sum of the events' `input_cache_read_image_tokens` quantities.
        - `input_cache_read_video_tokens` string: The sum of the events' `input_cache_read_video_tokens` quantities.
        - `input_cache_write_tokens` string: The sum of the events' `input_cache_write_tokens` quantities.
        - `input_cache_write_text_tokens` string: The sum of the events' `input_cache_write_text_tokens` quantities.
        - `input_cache_write_audio_tokens` string: The sum of the events' `input_cache_write_audio_tokens` quantities.
        - `input_cache_write_image_tokens` string: The sum of the events' `input_cache_write_image_tokens` quantities.
        - `input_cache_write_video_tokens` string: The sum of the events' `input_cache_write_video_tokens` quantities.
        - `output_tokens` string: The sum of the events' `output_tokens` quantities.
        - `output_text_tokens` string: The sum of the events' `output_text_tokens` quantities.
        - `output_audio_tokens` string: The sum of the events' `output_audio_tokens` quantities.
        - `output_reasoning_tokens` string: The sum of the events' `output_reasoning_tokens` quantities.
        - `accepted_prediction_tokens` string: The sum of the events' `accepted_prediction_tokens` quantities.
        - `rejected_prediction_tokens` string: The sum of the events' `rejected_prediction_tokens` quantities.
        - `realtime_audio_ms` string: The sum of the events' `realtime_audio_ms` quantities.
        - `reported_total_tokens` string: The sum of the events' `reported_total_tokens` quantities.
        - `total_input_tokens` string: The events' total input, cached or not: the sum of `input_tokens`, `input_cache_read_tokens`, and `input_cache_write_tokens`. A missing quantity counts as zero, and modality detail quantities aren't added.
        - `subjects` string: The number of distinct subjects among the events. Unattributed events don't count. A subject whose events fall in several groups counts once in each, so the groups' counts can add up to more than the overall count. Only a request without `granularity` can name it.
  - `meta` object, required: Information about the page.
    - `page` object, required: The page size and the cursors for the pages before and after this one.
      - `size` integer, required: The page size: the request's `page.size`, or `20` when the request omits it.
      - `next` string, nullable, required: The cursor for the next page, to send back as `page.after` in an otherwise identical body. `null` when there is no next page.
      - `previous` string, nullable, required: The cursor for the previous page, to send back as `page.before` in an otherwise identical body. `null` when there is no previous page.

## Other responses

- `400`: The request body is invalid. `invalid_parameters` names each invalid field. For example, `ends_at` isn't after `starts_at`, or the range spans more than 400 buckets. For CSV, remove the body field `page` to request all matching rows.
- `401`: The request has no valid access token. The token is missing, malformed, or expired, or it fails another check, and the response doesn't say which.
- `403`: The access token is valid, but its principal lacks the permission this operation requires. For an operation on one resource, the response doesn't reveal whether that resource exists.

## Changes

- **2026-11-19** `3b071797f6e4`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kong/apis/konnect-api-go-sdk/changes/v1/ai-cost-management/events/query/post.md)

---

[API](https://skmtc.dev/kong/apis/konnect-api-go-sdk.md) - [All operations](https://skmtc.dev/kong/apis/konnect-api-go-sdk/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4?raw)
