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

# Report usage events

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

## Request

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

**Pre-release Endpoint**
This endpoint is currently in beta and is subject to change.

Reports usage from AI model calls that didn't pass through the gateway, such as the model calls of an agent tool. Each event is an `ai.usage.v1` event without `source`. The service assigns `source` as `//principals/{uuid}` for the reporting principal. If an event includes `source`, the request fails with `400`.

- The service validates the whole request before it accepts anything. If any event is invalid, the request fails with `400` and no event is accepted.
- The service responds only after every event is queued for storage. It then stores the events asynchronously. They appear in the event list, where `filter[source]=//principals/{uuid}` selects them, and they count toward budgets like gateway usage.
- If the service can't confirm every event in time, the request fails with a server error, and some events may already be accepted. Retrying the same request is safe, because a repeated event collapses into the stored one. The reporting principal's `source`, the event's `id`, and its `time` identify a stored event. A retry that changes `id` or `time` stores a second event, and a retry that changes only other data replaces the stored event with whichever copy is stored last.
- An event that reaches the service more than 1 hour after its `time` is accepted, and `filter[arrival]=late` selects it.

## Request body

- object
  - `data` object[], required: The usage events to report. Each is an `ai.usage.v1` event without `source`, which the service assigns. 1 to 100 events. Each `id` can appear only once in the request. Each `time` is no more than 72 hours before the request arrives and no more than 5 minutes after it.
    - `specversion` '1.0', required: The CloudEvents version that the event follows. Always `1.0`.
    - `id` string, required: Identifies the invocation. `source` and `id` together identify the event. The `id` is unique within `source` and stays the same when the producer delivers the same invocation again. A client's retry of a model call is a separate invocation with its own `id`. A gateway event's `id` begins with `{request_id}/`.
    - `type` 'ai.usage.v1', required: The CloudEvents type of the event. Always `ai.usage.v1`: the event records one billable call to an AI model (an invocation).
    - `subject` string: The actor accountable for the invocation, as a reference in `type/id` form: - `principal/{uuid}`: a Kong Identity principal. This is the preferred form. - `consumer/{uuid}`: a gateway consumer or an AI Gateway consumer. - `oidc/{sub}`: the `sub` claim of the caller's OIDC credential, when nothing else identifies the caller. A UUID is lowercase and can't be the nil UUID. A `sub` has 1 to 255 characters and no line break. The event omits `subject` when no accepted identity is known, which leaves the usage unattributed.
    - `datacontenttype` 'application/json': The media type of `data`. Always `application/json`. The event list doesn't return it.
    - `dataschema` string, uri: The URI of the JSON Schema that `ai.usage.v1` events follow. The event list doesn't return it.
    - `traceparent` string: The W3C Trace Context `traceparent` of the model call, from the CloudEvents distributed tracing extension. Set only from a complete and valid `traceparent` value. A trace ID in another format belongs in `provenance`.
    - `tracestate` string: The W3C Trace Context `tracestate` that goes with `traceparent`.
    - `data` object, required: The usage the event reports: `quantities`, `reported_cost`, `reported_cache_cost`, `context`, and `optimization`, plus the `provenance`, `tags`, `groups`, and `teams` that attribute it.
      - `quantities` object, required: The quantities the invocation used, keyed by kind. Each value is a count in the kind's unit, such as tokens or milliseconds. An omitted kind is unknown, not zero, and the object can be empty. A kind not listed here isn't accepted. The event list returns every kind and shows an unreported kind as `"0"`.
        - `input_tokens` string: Uncached input tokens, without a per-modality breakdown. A producer reports either this total or the per-modality uncached input kinds, such as `input_text_tokens`. When both appear, they can count the same tokens.
        - `input_text_tokens` string: Uncached text input tokens.
        - `input_audio_tokens` string: Uncached audio input tokens.
        - `input_image_tokens` string: Uncached image input tokens.
        - `input_cache_read_tokens` string: Input tokens read from the provider's cache, without a per-modality breakdown. They aren't part of uncached input or cache writes. A producer reports either this total or the per-modality cache-read kinds, such as `input_cache_read_text_tokens`. When both appear, they can count the same tokens.
        - `input_cache_read_text_tokens` string: Cache-read text input tokens.
        - `input_cache_read_audio_tokens` string: Cache-read audio input tokens.
        - `input_cache_read_image_tokens` string: Cache-read image input tokens.
        - `input_cache_read_video_tokens` string: Cache-read video input tokens.
        - `input_cache_write_tokens` string: Input tokens written to the provider's cache, without a per-modality breakdown. They aren't part of uncached input or cache reads. A producer reports either this total or the per-modality cache-write kinds, such as `input_cache_write_text_tokens`. When both appear, they can count the same tokens.
        - `input_cache_write_text_tokens` string: Cache-write text input tokens.
        - `input_cache_write_audio_tokens` string: Cache-write audio input tokens.
        - `input_cache_write_image_tokens` string: Cache-write image input tokens.
        - `input_cache_write_video_tokens` string: Cache-write video input tokens.
        - `output_tokens` string: Output tokens, without a per-modality breakdown. A producer reports either this total or the per-modality output kinds, such as `output_text_tokens`. When both appear, they can count the same tokens.
        - `output_text_tokens` string: Text output tokens.
        - `output_audio_tokens` string: Audio output tokens.
        - `output_reasoning_tokens` string: Reasoning output tokens.
        - `accepted_prediction_tokens` string: Prediction tokens that the provider reports as accepted.
        - `rejected_prediction_tokens` string: Prediction tokens that the provider reports as rejected.
        - `realtime_audio_ms` string: The duration of realtime audio, in milliseconds.
        - `reported_total_tokens` string: The provider's own total token count, kept to reconcile against the other kinds. It isn't billable and never enters a cost. A producer sends it only when the provider reports it, never as a sum of other kinds.
      - `reported_cost` object: The producer's estimate of the invocation's cost, such as `{"value": "0.0054", "currency": "USD"}`. Usage queries, forecasts, and budgets sum it as reported. `value` is `0` to `999999999.999999999`, with at most 9 digits before the decimal point and at most 9 after it. It has no sign, no exponent, and no extra leading zeros (`0.5` is valid, `00.5` isn't). Trailing fractional zeros are accepted, and the event list returns the value without them. An omitted cost is unknown, not zero. A producer that knows the cost is zero sends a `value` of `"0"`. The event list returns an omitted cost with a `value` of `"0"`.
        - `value` string, required
        - `currency` 'USD', required: The currency of `value`.
      - `reported_cache_cost` object: The producer's estimate of the part of `reported_cost` that comes from cache reads and cache writes. Its `value` has the same format and bounds as `reported_cost`'s. An omitted value is unknown, not zero. The event list returns it with a `value` of `"0"`.
        - `value` string, required
        - `currency` 'USD', required: The currency of `value`.
      - `context` object, required: What served the invocation and how: the `provider` and `model`, the model's registry identifier in `model_id`, the `request_mode`, the provider's `region`, and the calling tool in `client`. The producer omits each field it doesn't know. A field that's present is never empty.
        - `provider` string: The AI provider that served the invocation.
        - `model` string: The model that served the invocation, as the provider reports it, after any alias resolution, route selection, fallback, or enforced downgrade. When the provider doesn't report it, the producer omits `model` rather than putting the requested model in its place.
        - `model_id` string: The producer's stable identifier for the model in its model registry.
        - `request_mode` 'stream' | 'oneshot' | 'realtime': How the invocation was served: `stream`, `oneshot`, or `realtime`.
        - `region` string: The region of the provider that served the invocation, not the region of the gateway's data plane.
        - `client` string: The tool that made the call, such as `claude_code`, `codex`, or `copilot`, as a normalized identifier. The caller can influence it, so it isn't verified.
      - `optimization` object: Evidence about cost-saving mechanisms applied to the invocation: a semantic cache and prompt compression. Nothing in it is billable or enters a cost.
        - `semantic_cache` object: Evidence from the semantic cache lookup for the invocation.
          - `status` string: The semantic cache's status for the invocation, in the producer's own terms.
          - `embeddings_provider` string: The provider of the embedding model that the cache lookup used.
          - `embeddings_model` string: The embedding model that the cache lookup used.
          - `embeddings_tokens` string: The number of tokens that the cache lookup embedded.
        - `compression` object: Evidence from prompt compression for the invocation.
          - `status` string: The prompt compression status for the invocation, in the producer's own terms.
          - `input_tokens_before` string: The total input tokens before compression. After compression, the total input is the sum of the uncached, cache-read, and cache-write input quantities.
      - `provenance` object, required: Identifiers from the producer's own systems: the gateway entities and configuration that handled the request, the identity evidence behind `subject`, and identifiers that correlate the event with other data. At most 64 entries, each with a key of 1 to 128 characters. The keys this schema lists have fixed types. Any other key takes a non-empty string, which the event list doesn't return.
        - `request_id` string: The identifier of the request that made the invocation, for correlating the event with other data.
        - `workspace_id` string, uuid: The gateway workspace that handled the request.
        - `service_id` string, uuid: The gateway service that handled the request.
        - `route_id` string, uuid: The gateway route that the request matched.
        - `plugin_id` string, uuid: The gateway AI plugin that handled the invocation.
        - `consumer_id` string, uuid: The gateway consumer that made the request.
        - `consumer_group_ids` string[]: The gateway consumer groups that the request's consumer belongs to. At most 64 identifiers.
        - `application_id` string, uuid: The application that made the request.
      - `tags` object, required: Key-value context that the caller controls, such as a `project` or `scm-repository` tag, used to attribute and group usage. At most 64 tags. A key has 1 to 128 characters, each a lowercase ASCII letter, a digit, `.`, `_`, or `-`. A value has 1 to 256 characters, none of them a control character. Values are case-sensitive. Key order carries no meaning, and the service sorts tags by key.
      - `groups` string[]: The groups the usage belongs to: every group the producer knows, as the producer supplies them. Each is a reference in `type/id` form: `principal/{uuid}` for a Kong Identity group, `consumer_group/{uuid}` for a Kong consumer group, or `oidc/{group}` for an OIDC group. The service doesn't verify them, and none is the primary group. At most 328 references, each listed once. A UUID is lowercase. An OIDC group has 1 to 255 characters, contains no comma or line break, and keeps its text and case. The service sorts the references lexicographically.
      - `teams` string[]: The Kong Identity teams the usage belongs to, as the producer supplies them. Each is a `principal/{uuid}` reference to a Kong Identity principal group of type `team`. The service doesn't verify them, and none is the primary team. A `team` tag is an ordinary tag and doesn't fill `teams`. At most 200 references, each listed once. A UUID is lowercase. The service sorts the references lexicographically.

## Response `202`

Every event was accepted for storage. The body lists each event's `id` and `source`, in request order.

- object
  - `data` object[], required: The `id` and `source` of each accepted event, in request order. Together they identify the event once it's stored.
    - `id` string, required: The event's `id`, as the request reported it.
    - `source` string, required: The `source` that the service assigned: `//principals/{uuid}`, where `{uuid}` is the reporting principal's identifier in lowercase.

## Other responses

- `400`: The request body is invalid. `invalid_parameters` names each invalid field. A field inside an event is named with the event's position, such as `data[3].time`.
- `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/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)
