Enterprise

List organization AI spend by user

Changed on

Returns one page of per-user AI spend for the organization, most expensive first, built from the same raw AI Gateway token usage as the CSV export so the two reconcile. Each user lists the providers and clients they spent through, and the response carries the user count, total spend, and unpriced usage count over every matching user. The optional period_start and period_end query parameters bound the period and are interpreted as UTC. They must be provided together and span at most 31 days. When both are omitted, the current UTC monthly period is used. An explicit period_start must fall within the configured AI Gateway data retention window, since older token usage is purged. The default period is narrowed to that window instead. The response echoes the applied bounds and, when retention is enabled, the start of the retention window. The optional provider_name, model, and client query parameters restrict the spend report to usage matching all supplied filters. Use client=Unknown for usage with an unknown or missing client. Unknown query parameters are rejected. Requires organization-level administrator permissions.

get/api/experimental/organizations/{organization}/ai/spend/users

Request

  • Base URL
    / (relative, and the document was published on a file host, not at the API’s origin)
  • URL
    /api/experimental/organizations/{organization}/ai/spend/users
  • Auth
    API key in header Coder-Session-Token

Path parameters

organizationstring uuid required

Organization ID

Query parameters

period_startstring date-time

Inclusive lower bound (RFC3339)

period_endstring date-time

Exclusive upper bound (RFC3339)

provider_namestring

Only include usage through this provider configuration name

modelstring

Only include usage of this model

clientstring

Only include usage from this client. Unknown matches usage without a recorded client.

limitinteger

Page size (default 10, maximum 100)

offsetinteger

Page offset

Response

OK

countinteger

Count is the number of users with token usage matching the filter.

period_endstring date-time

PeriodEnd is the exclusive upper bound of the current budget period.

period_startstring date-time

PeriodStart is the inclusive lower bound of the current budget period.

retention_startstring date-time

RetentionStart is the oldest instant for which token usage is still retained. An explicit period must not start before it. Omitted when the deployment does not purge AI Gateway data.

Changes