Export organization AI spend as CSV
Returns per-user, per-group, per-model, per-provider aggregated AI spend for the organization as CSV, built from raw AI Gateway token usage. 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, and every row echoes the applied bounds. Unknown query parameters are rejected. Requires organization-level administrator permissions.
CoderSessionTokenCoder-Session-Token<token>organization*stringOrganization ID
uuidperiod_start?stringInclusive lower bound (RFC3339)
date-timeperiod_end?stringExclusive upper bound (RFC3339)
date-timeuser_id?stringUser ID
uuidgroup_id?stringEffective group ID
uuidprovider_name?stringConfigured provider name
model?stringModel name
The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X GET \ "$CODER_URL/api/v2/organizations/{organization}/ai/spend/export" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN"