Skip to content

feat: add organization AI spend overview endpoint - #31709

Draft
ssncferreira wants to merge 1 commit into
ssncf/ai-spend-overview-queriesfrom
ssncf/ai-spend-overview-endpoint
Draft

ssncferreira wants to merge 1 commit into
ssncf/ai-spend-overview-queriesfrom
ssncf/ai-spend-overview-endpoint

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the experimental GET /api/experimental/organizations/{organization}/ai/spend endpoint that backs the new Overview tab of the organization AI spend page. It returns the organization's spend summary, daily spend, and a page of users with their per-group spend, using the queries from #31711.

Changes

  • Add the organizationAISpend handler and ExperimentalClient.OrganizationAISpend:
    • Reuses the existing period handling (period_start/period_end together, at most 31 days, default to the current UTC month narrowed to retention). Bounds must be at UTC midnight; a default period narrowed by retention starts at the next UTC day.
    • Returns count, totals (spend_micros, median_spend_micros), daily (one bucket per UTC day, zeros included), and users (paginated with limit/offset, most spend first, with per-group spend).
    • Echoes the applied period, but every value covers it only through today, read in one read-only repeatable-read transaction so the values agree.
  • Extract parseOrganizationAISpendPage, shared with /ai/spend/users.
  • Add handler tests.

Closes AIGOV-728

Note

Generated by Coder Agents on behalf of @ssncferreira.

@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown

AIGOV-728

@ssncferreira
ssncferreira force-pushed the ssncf/ai-spend-overview-endpoint branch from 19849a9 to 793d96e Compare November 3, 2026 20:03
@ssncferreira
ssncferreira changed the base branch from main to ssncf/ai-spend-overview-queries November 3, 2026 20:04
@ssncferreira
ssncferreira added this pull request to stack #31712 November 3, 2026 20:04
@ssncferreira
ssncferreira force-pushed the ssncf/ai-spend-overview-endpoint branch from 793d96e to af5b8bd Compare November 3, 2026 20:11

This branch has not been deployed

No deployments
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