Repository navigation
feat!: add the client to the AI spend CSV export - #32474
Merged
Merged
Conversation
ssncferreira
force-pushed
the
ssncf/ai-spend-export-client
branch
5 times, most recently
from
November 23, 2026 18:07
ac860e8 to
a75033a
Compare
ssncferreira
force-pushed
the
ssncf/ai-spend-export-client
branch
from
November 23, 2026 18:10
a75033a to
a1fdc8e
Compare
ssncferreira
marked this pull request as ready for review
November 23, 2026 18:11
ssncferreira
requested review from
SasSwart,
ibetitsmike and
johnstcn
as code owners
November 23, 2026 18:11
ibetitsmike
approved these changes
Nov 24, 2026
mollymaefraser
approved these changes
Nov 24, 2026
mollymaefraser
left a comment
Collaborator
There was a problem hiding this comment.
LGTM 🚀 few nits but not blocking
| AND (@group_id::uuid = '00000000-0000-0000-0000-000000000000'::uuid OR tu.effective_group_id = @group_id) | ||
| AND (@provider_name::text = '' OR ai.provider_name = @provider_name) | ||
| AND (@model::text = '' OR ai.model = @model) | ||
| AND (@client::text = '' OR COALESCE(ai.client, 'Unknown') = @client::text) |
Collaborator
There was a problem hiding this comment.
nit: Can ai.client ever hold a real value of Unknown, or an empty string ''? An Unknown value would merge with NULL. A '' value can't be filtered for, because client= means "no filter". This matches /ai/spend/users, so it's fine if the client values come from a fixed set. I just want to confirm.
Collaborator
Author
There was a problem hiding this comment.
The client values come from a fixed set. AI Gateway resolves the client from the request headers, and stores Unknown when it can't. So currently, a client can't be stored as ''.
ssncferreira
had a problem deploying
to
docs-preview
November 24, 2026 09:48 — with
GitHub Actions
Failure
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds the client to the stable
GET /api/v2/organizations/{organization}/ai/spend/exportCSV export, so the Detailed report page (#32482) can export the same data with the same filters.Changes
ExportOrganizationAISpendgroups rows by client as well, and takes aclientfilter. Usage without a recorded client is reported asUnknown, like/ai/spend/users.clientquery parameter, and adds aclientcolumn at the end of the CSV, so existing columns keep their position.OrganizationAISpendDetailsFiltertakes aClient.Breaking change
The AI spend CSV export (
GET /api/v2/organizations/{organization}/ai/spend/export) now has aclientcolumn at the end, and splits rows by it.If you rely on one row per user, group, model and provider, sum
cost_microsand the token columns across clients to get the previous totals.Closes AIGOV-733
Note
Generated by Coder Agents on behalf of @ssncferreira.