Repository navigation
feat: filter the organization AI spend export by provider, model, and client - #29224
ibetitsmike wants to merge 3 commits into
Conversation
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
2771be8 to
dc7b500
Compare
903e233 to
3a53085
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3a53085 to
a307401
Compare
dc7b500 to
07c3acd
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
07c3acd to
dcaab5d
Compare
a307401 to
7f9d14c
Compare
|
This PR was reworked in place on 2026-09-15: the stack now extends the released organization spend export ( @codex review
|
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
dcaab5d to
8fbedad
Compare
7f9d14c to
f434067
Compare
|
Re-requesting review on the current head after the stack rebase (same content, new commit). @codex review
|
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…l, and client Add optional provider_name, model, and client parameters to ExportOrganizationAISpend, matching the predicates ListOrganizationAISpendUsers already applies. An empty value matches everything, and client compares against COALESCE(client, 'Unknown') like the AI Gateway sessions list. The export handler passes empty filters for now; exposing them as query parameters follows separately. Cover the filters on the export and add a reconciliation test that sums the export per user and compares it with the user report for every filter combination, so the two queries cannot drift apart silently.
Add OrganizationAISpendFilter, which carries the period plus the optional provider_name, model, and client dimensions for the organization AI spend export, and switch ExportOrganizationAISpend to it. Add OrganizationAISpendReport and OrganizationAISpendUser, the paginated per-user JSON representation of the same export, with OrganizationAISpend requesting it through Accept: application/json. The server side of the filters and the JSON representation follows in the next changes; existing callers keep receiving CSV.
… client
Accept optional provider_name, model, and client query parameters on
GET /organizations/{organization}/ai/spend/export and pass them to the
export query. Parse every parameter with one query parser so unknown
parameters are rejected with 400 regardless of whether a period is given;
previously only requests with an explicit period were checked.
Cover each filter, the Unknown client, empty filters, and the uniform
unknown-parameter rejection.
8fbedad to
4c5c20a
Compare
f434067 to
d0b0237
Compare
4c5c20a to
1bba66b
Compare
|
Closing: this stack was reshaped to drop the CSV export dimension filters. The Spend page reads the per-user JSON report (
|
Fourth of a six-PR stack that reworks the AI spend page onto the released organization spend export,
GET /api/v2/organizations/{organization}/ai/spend/export, and a sibling per-user endpoint,GET /api/v2/organizations/{organization}/ai/spend/users, instead of the deployment-wide/api/v2/ai-gateway/spend/*endpoints this stack previously proposed. Every PR in the stack was rewritten in place from current main; the head branch name predates the rework. The export's accounting rules are unchanged: token usage bycreated_atin[period_start, period_end), attributed to the organization through the effective budget group, so the page reconciles with the CSV and with daily budget accounting.The export handler parses every query parameter with one
QueryParamParser, soprovider_name,model, andclientreach the CSV query and unknown parameters fail with 400 whether or not a period is given. Previously the excess-parameter check only ran in the explicit-period branch.Includes the regenerated API docs and endpoint tests for each filter and for the uniform excess-parameter rejection.