Exports in AI Cost Management

OpenAPI Specifications
Minimum Version
AI Gateway - 2.3
Incompatible with
on-prem

Exports in AI Cost Management write your stored usage events to downloadable files. Use them to analyze spend in a spreadsheet, load it into a data warehouse, or reconcile it with a model provider’s FOCUS data.

Create a one-time export to answer a question about a specific time range. Create a schedule to keep a recurring copy, for example a daily file for your finance team’s reporting.

Configuration

Configuration options control what data an export holds, what format its files use, and how FOCUS rows are structured.

Datasets

The dataset controls what each row in an export holds and how the files divide the time range.

Dataset

What it holds

Files

usage_events One row per stored usage event, with the same fields the Events list shows. One file per day of the range.
focus Cost and usage rows in the FinOps FOCUS format, for tools that load cloud spend. One file per calendar month of the range.

File formats

Exports are available in the following formats:

Format

Compression

Extension

Best for

CSV None .csv Spreadsheets and tools that import CSV.
CSV (gzip) gzip .csv.gz Smaller downloads over slow connections.
Parquet Zstandard .parquet Data warehouses and analytics tools.

A period with no matching events still produces a file, with a header row only (CSV) or zero records (Parquet).

FOCUS options

FOCUS exports have additional options that control how rows are formed and what the cost columns hold.

FOCUS version

The FOCUS version controls what the standard cost columns (BilledCost, EffectiveCost, ListCost, ContractedCost) hold. Both versions carry the AI Gateway-reported cost estimate in x_ReportedCost.

Warning: If you load a FOCUS 1.3 file alongside a model provider’s own FOCUS data, the standard cost columns count the same spend twice. Use FOCUS 1.4 when combining exports with provider data.

Version

Standard cost columns

1.3 The AI Gateway-reported cost estimate. Counts the same spend as the provider’s FOCUS data.
1.4 0. The estimate is in x_ReportedCost only. Safe to combine with provider data.

Charge period

The charge period sets the length of each FOCUS row’s aggregation window, in the export’s time zone.

  • day produces one row per calendar day
  • hour produces one row per hour

An hour charge period also reduces the risk of a query_limit_exceeded failure on large datasets.

Tag keys

Tag keys name the tag dimensions that split FOCUS rows. A row’s Tags column holds each configured key and its value for the events the row aggregates. Each key must be between 1 and 128 characters, and a FOCUS export supports at most 64 tag keys.

Export lifecycle

The export lifecycle covers how an export progresses after creation, how to download its files, and how scheduled exports behave.

Status

An export runs asynchronously, and the status field tracks its progress.

Status

Description

pending The export is queued. One export per organization runs at a time.
running The export is in progress. AI Cost Management is reading events and writing files.
succeeded Files are ready to download, until expires_at (30 days after the export finishes).
failed The export stopped without files. Check the failure_reason.
expired The export succeeded but its 30-day download window has passed. The export record remains with its file list, but the files are deleted.

Downloading files

You can download files from a successful export through short-lived URLs that the API returns. Each URL is valid for five minutes and works with a plain GET request without an Authorization header.

Warning: A download URL is a bearer credential. Anyone who holds it can download the file until it expires.

Each file in the export’s files list has a size_bytes and a sha256 field. The manifest.json file describes the export and lists each data file with its size and SHA-256 digest.

The files list doesn’t include the manifest. To download it, request a download URL with manifest.json as the filename. You can verify a download by comparing its size and SHA-256 checksum against those values.

Scheduled exports

A scheduled export runs automatically at the end of each period. Usage events don’t always arrive in real time. The export starts six hours after the period ends, so that events that arrive late can be stored first. For example, a request that happens at 11:58 PM might not be processed and stored until 1 AM.

Each schedule exports each period once and never refreshes it, even when events arrive after the export ran. A failed scheduled export stays failed and the schedule doesn’t retry it. To capture late events or fill a failed period, create a one-time export of the same range.

When a schedule resumes from paused, the periods that ended while it was paused are skipped. After an outage, a schedule catches up on at most the 31 most recent periods that ended while it was active.

To change a schedule, send a PUT request to the /v1/ai-cost-management/export-schedules/{scheduleId} endpoint with the full schedule, because an omitted filters clears the filters. Set status to paused to pause the schedule and to active to resume it. The change applies to periods that end after it, and existing exports don’t change.

Set up an export

You can create a one-time export or a recurring schedule from the Konnect UI or the API.

Set up a one-time export

Set up a scheduled export

Limitations

Exports and export schedules are subject to the following limits.

Limit

Value

Maximum range 13 months
Pending one-time exports 20 at a time
Export schedules 20
FOCUS tag keys 64 per export
File retention 30 days after the export succeeds
Download URL lifetime 5 minutes

Exports that a schedule creates don’t count toward the pending one-time export limit.

The following limitations also apply:

  • An export runs once and is never refreshed. A later export of the same range can hold events an earlier one doesn’t have, because events can arrive after the range ends.
  • Export files stay in the region where they were created.
  • Labels on a one-time export can’t change after creation.
  • A schedule’s cadence and time_zone can’t change after creation. Delete the schedule and create a new one to change either field.

Schema

FAQs

Call GET /v1/ai-cost-management/exports/{exportId} and check the failure_reason field in the response:

  • A query_limit_exceeded failure means the export read more data than one job can use. Try a shorter range, narrower filters, fewer FOCUS tag keys, or a smaller charge period (for example, hour instead of day).
  • An attempts_exhausted failure means every attempt hit a transient error. If you see this error, create the same export again.

Files are only downloadable from an export with status: succeeded. Exports expire after 30 days, and their files are deleted.

An export that is still pending or running hasn’t produced files yet.

Scheduled exports start six hours after a period ends so that late events can be stored first, but events can still arrive after that window. A one-time export run later includes any events that arrived after the scheduled export ran. Scheduled exports are never refreshed. To capture late events for a past period, create a one-time export.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!