Files
coder/coderd
Sas Swart 5baa8eff01 feat: price AI Gateway token usage with the request organization (2/2) (#31121)
Cost looks up model prices site-wide only, so an organization's own
prices never apply, even though #31118 now stores the request
organization on each interception.

Pass the interception's stored organization to
`GetAIModelPriceForProvider`. The lookup already falls back from the
organization's price to the site-wide custom price, then to the price
book. An interception without an organization (old rows, old gateways)
uses only site-wide prices, as before.

| Stored org | Org price | Site-wide custom | Price used |
|---|---|---|---|
| none | any | any | site-wide custom, then price book |
| B | live | any | B's price |
| B | soft-deleted or absent | present | site-wide custom |
| B | absent | absent | price book, or NULL cost |

Remove `TODO(AIGOV-716)`. Make `TestRecordTokenUsageAuthorized` store an
organization and assert that its price wins under the strict authorizer.

Part of AIGOV-716. Stacked on #31120.

---

*This PR was generated by Coder Agents on behalf of @SasSwart.*
2026-10-30 13:35:23 +02:00
..