Skip to content
Skip to Content
Coder Docs

Export organization AI spend as CSV

GET
/api/v2/organizations/{organization}/ai/spend/export

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.

Authorization

CoderSessionToken
headerCoder-Session-Token<token>

Path Parameters

organization*string

Organization ID

Formatuuid

Query Parameters

period_start?string

Inclusive lower bound (RFC3339)

Formatdate-time
period_end?string

Exclusive upper bound (RFC3339)

Formatdate-time
user_id?string

User ID

Formatuuid
group_id?string

Effective group ID

Formatuuid
provider_name?string

Configured provider name

model?string

Model name

Response Body

OK

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"
Example Response200
Empty