AI cost governance (FinOps for AI)
Make AI spend visible, owned and predictable: tag every call at the gateway by team, feature and customer, track cost per business outcome, and pull the cheap levers before buying commitments.
Analogy: A shared office electricity bill that nobody owns keeps growing. Put a meter on each floor, show each team its own number, and lights start going off at night.
How it works
- You pay per token, so a prompt edit is a cost change; spend follows usage, not provisioned servers.
- Reject untagged calls or show them as unallocated; start with showback, then chargeback once the numbers are trusted.
- Track unit cost, such as cost per resolved ticket: total spend rising is fine if unit cost falls.
- Cheapest levers first: trim prompts, cap output, caching, routing to smaller models, batch for non-interactive work.
- Self-hosted, GPU utilization is the whole game: an idle GPU costs the same as a busy one.
Check yourself
Answer to mark it learned; your answers aren't scored.
Finance wants the support copilot's $38k/month bill cut. Gateway tags show most spend is one feature, summarize thread, called on every page load with a 12k-token prompt. Which plan do you lead with?
Go deeper
Full explanation
AI FinOps applies the FinOps Foundation's Inform → Optimize → Operate loop to model spend. Two things change: you pay per token, so a prompt edit is a cost change, and spend follows usage, not servers you provisioned.
The loop:
- Attribute. Every call goes through the LLM gateway tagged with
team,feature,customer,env. Untagged calls are rejected or land in a visible unallocated bucket. Start with showback (each team sees its bill); move to chargeback once the numbers are trusted. - Budget and alert. Monthly budget per team, alerts on forecast to exceed and on day-over-day spikes, hard caps on dev keys and agent loops.
- Unit economics. Divide cost by the outcome the business pays for: cost per resolved ticket, per processed document, per active user. Total spend rising is fine if unit cost falls.
- Optimize, cheapest lever first. Trim prompts and cap output tokens, Prompt caching, Model routing & cascades to smaller models, Semantic caching, Batch inference for anything not interactive. Self-hosted: watch GPU utilization, because an idle GPU costs the same as a busy one.
- Commit and forecast. Only on a stable baseline, buy reserved or provisioned capacity. Forecast as users × calls per user × tokens per call × price, and redo it when any factor moves.
Code Cost per feature and per outcome from gateway logs
-- Last 30 days, prod only. gateway_logs: one row per LLM call, tagged at the gateway.
-- model_prices: USD per 1M tokens with validity dates, because prices change.
WITH spend AS (
SELECT COALESCE(g.feature, 'UNALLOCATED') AS feature, -- make missing tags visible
SUM( g.uncached_input_tokens * p.input_usd_per_m
+ g.cached_input_tokens * p.cached_input_usd_per_m
+ g.output_tokens * p.output_usd_per_m ) / 1e6 AS cost_usd,
COUNT(*) AS calls
FROM gateway_logs g
JOIN model_prices p
ON p.model = g.model
AND g.ts >= p.valid_from AND g.ts < p.valid_to
WHERE g.ts >= CURRENT_DATE - INTERVAL '30 days'
AND g.env = 'prod'
GROUP BY 1
),
results AS ( -- the outcome the business pays for, from the product's own tables
SELECT feature, COUNT(*) AS outcomes -- e.g. resolved tickets, processed documents
FROM business_outcomes
WHERE ts >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY feature
)
SELECT s.feature,
s.calls,
ROUND(s.cost_usd, 2) AS cost_usd,
r.outcomes,
ROUND(s.cost_usd / NULLIF(r.outcomes, 0), 4) AS cost_per_outcome
FROM spend s
LEFT JOIN results r USING (feature)
ORDER BY s.cost_usd DESC;Real example
A support copilot costs $38k a month and finance wants it cut. Gateway tags show most of the spend is one feature: summarize thread, called on every page load with a 12k-token prompt. Cost per resolved ticket is $1.90. The team caches the summary per thread version, trims the system prompt from 4k to 1.5k tokens, caps output at 300 tokens, routes intent classification to a small model and moves nightly QA scoring to the batch API. Each change passes the eval set first. Spend drops to ~$17k with resolved tickets flat, so cost per ticket falls to ~$0.85, and that unit number, not the total, goes into the quarterly review.
Trade-offs +3 · −3
+ You gain
- Turns "AI is expensive" into named owners, features and unit costs you can act on.
- Unit economics separate healthy growth from waste: spend can rise while cost per outcome falls.
- Catches runaway agent loops and leaked keys in hours, not on the month-end invoice.
− You pay
- Tagging discipline is real work; untagged spend quietly becomes nobody's problem.
- Chargeback too early breeds disputes and teams gaming tags instead of optimizing.
- Cost cutting without evals silently degrades quality and can raise cost per outcome.
Use it when
As soon as AI spend is a line item someone asks about: several teams share providers, a feature runs per user or per document, or you are about to sign a commitment.
Avoid it when
A single prototype on a capped card: the provider dashboard and a hard budget are enough. Don't build chargeback before anyone is spending real money.
Numbers to know 4
- Batch APIs (OpenAI, Anthropic) bill asynchronous jobs at ~50% of the synchronous price, with up to 24 h turnaround.
- Output tokens list at several times the input price on major APIs (4× and 5× are common), so output caps pay off early.
- Forecast: monthly cost ≈ active users × calls per user × tokens per call × blended price per token.
- Self-hosted: cost per token = GPU cost per hour ÷ tokens actually served per hour. Utilization is the whole game.
Common pitfalls 4
- Attributing by API key only: a key shared by three features tells you nothing. Tag feature and customer per request.
- Alerting at 100% of budget, when the money is already spent. Alert on forecast and on spikes.
- Switching to a cheaper model without an eval: it resolves fewer tickets and cost per resolved ticket goes up.
- Committing to capacity on a launch-month baseline, then migrating models and paying for capacity you no longer use.
Interview questions 3
Answer out loud first, then reveal.
Finance says AI spend tripled this quarter. What do you do?Show answer
First I separate growth from waste. I break spend down by feature and model from the gateway logs and divide by the business outcome. If usage tripled and cost per resolved ticket is flat or falling, that is success, and I say so with the unit number. If unit cost rose, I find the cause: a new agent loop, a prompt that grew, a model upgrade nobody re-priced. Then I pull the cheapest levers first, prompt trimming, output caps, caching, routing, batch, each gated by our evals so quality doesn't regress quietly.
When would you commit to reserved or provisioned capacity?Show answer
Only when the baseline is stable and I know which model it runs on. A commitment trades flexibility for a discount, and in AI the price of a given capability keeps falling and we change models often. So I commit to the floor of steady traffic, the trailing minimum rather than the peak, keep spikes on-demand, and prefer short terms or commitments that can move across models. For self-hosted GPUs I commit only after utilization is high, because idle reserved GPUs are pure waste.
How do you get teams to care about cost without slowing them down?Show answer
I make cost visible and owned rather than approved. Each team gets a showback dashboard with its spend and unit cost, a budget with alerts that go to the team, not to me, and hard caps only on dev keys and agent loops. Design review templates get one line: expected cost per request and per outcome. The trade-off is that some waste survives longer than under central approval, but I'd rather that than a ticket queue in front of every experiment.