Skip to content

feat: add provider, model, and client spend to the AI spend users endpoint - #32330

Draft
ssncferreira wants to merge 1 commit into
mainfrom
ssncf/ai-spend-user-details
Draft

ssncferreira wants to merge 1 commit into
mainfrom
ssncf/ai-spend-user-details

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Extends the experimental GET /api/experimental/organizations/{organization}/ai/spend/users endpoint with the per-user details behind the AI spend overview (the unpriced models tooltip and the cost details dialog) and the detailed report. Each user now returns their spend per provider, model, and client, and the number of models with unpriced usage.

Changes

  • Rewrite ListOrganizationAISpendUsers with GROUPING SETS, returning one row per user and provider, model, or client:
    • Adds the user_ids and group_id filters.
    • Pages, counts, and totals users, not their rows.
    • Reads the provider display name, icon, and type from ai_providers, including deleted providers. The live provider wins when a name was reused, like GetAIProviderFilterOptions.
    • Counts models with unpriced usage by name, so a model used through several providers counts once.
  • Update the SDK and handler:
    • Each user returns unpriced_model_count and provider_spend, model_spend, and client_spend, most expensive first.
    • totals returns has_unpriced_usage.
    • Remove the providers, clients, and models name arrays and unpriced_usage_count.
    • Accept user_ids (comma-separated, maximum 100) and group_id.
  • Switch the Spend page to the new fields, with no UI changes.
  • Update the query and handler tests.

Closes AIGOV-734

Note

Generated by Coder Agents on behalf of @ssncferreira.

@ssncferreira
ssncferreira temporarily deployed to main November 17, 2026 19:35 — with GitHub Actions Inactive
@ssncferreira
ssncferreira temporarily deployed to main November 17, 2026 19:35 — with GitHub Actions Inactive
@linear-code

linear-code Bot commented Nov 17, 2026

Copy link
Copy Markdown

AIGOV-734

@ssncferreira
ssncferreira temporarily deployed to main November 17, 2026 19:39 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
main — ea504bb9 Deployed Nov 17, 2026 by ssncferreira via cla #258910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant