Files
coder/coderd
Sas SwartandClaude Opus 5.5 dcbe84a23b feat: add organization member AI spend endpoint (#32203)
Adds `GET /api/v2/organizations/{organization}/members/{user}/ai/spend`,
which returns a user's effective AI budget and current-period spend
inside one organization. Admins, and users themselves, can use it to
look up spend in a specific organization.

The endpoint resolves the budget inside that organization only, the same
way AI Gateway resolves a request made there. The response has the same
shape as the user spend endpoint, plus `organization_id`.

Users can read their own spend, and admins can read the spend of a user
whose membership in that organization they can read. The endpoint
returns 404 when the user isn't a member of the organization, or when
the caller can't read the user. It requires the AI Governance license.

Organization admins can read every user, so only the organization and
membership checks keep them out of other organizations. The tests cover
both sides: an organization admin reading a member of their own
organization (200) and of another organization (404).

Also adds `Client.OrganizationMemberAISpendStatus` to `codersdk`, and
links the endpoint from `cost-controls.md`.

Stacked on #32202, which adds `GET
/users/{user}/ai/spend/organizations`. Review only the last two commits
here.

Refs [AIGOV-766](https://linear.app/codercom/issue/AIGOV-766)

---

*Generated by Coder Agents on behalf of @SasSwart.*

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 11:53:23 +02:00
..