Files
coder/coderd/database/queries
Susana Ferreira 1b9f2d8181 feat!: add the client to the AI spend CSV export (#32474)
## Description

Adds the client to the stable `GET
/api/v2/organizations/{organization}/ai/spend/export` CSV export, so the
Detailed report page (https://github.com/coder/coder/pull/32482) can
export the same data with the same filters.

## Changes

- `ExportOrganizationAISpend` groups rows by client as well, and takes a
`client` filter. Usage without a recorded client is reported as
`Unknown`, like `/ai/spend/users`.
- The export accepts a `client` query parameter, and adds a `client`
column at the end of the CSV, so existing columns keep their position.
- `OrganizationAISpendDetailsFilter` takes a `Client`.
- Update the Spend export docs and the query and handler tests.

## Breaking change

The AI spend CSV export (`GET
/api/v2/organizations/{organization}/ai/spend/export`) now has a
`client` column at the end, and splits rows by it.

If you rely on one row per user, group, model and provider, sum
`cost_micros` and the token columns across clients to get the previous
totals.

Closes AIGOV-733

> [!NOTE]
> Generated by Coder Agents on behalf of @ssncferreira.
2026-11-24 09:48:47 +00:00
..
…

queries

Database queries are generated using sqlc. See: sqlc docs

Run make gen to generate models and query functions.