AI workloads break classic FinOps assumptions: cost scales with tokens and GPU-hours, not instances; one bad prompt loop can burn a month's budget in an afternoon; and the bill arrives attributed to a gateway, not a team.
Tier: Advanced · Hands-on time: ~60 minutes
This playbook stands up the minimum viable cost-control layer for LLM and GPU workloads — per-team budgets, cost-per-request visibility, utilization tracking, and regression alerts — using gateway-native spend tracking rather than month-end billing archaeology.
Skip the GPU half if you are purely on hosted APIs; skip the gateway half only if a gateway is genuinely impossible (then budget enforcement moves to provider-level limits, which are much cruder).
Route all LLM traffic through the gateway with virtual keys. One virtual key per team/app — never shared provider keys. In LiteLLM: define teams, attach max_budget and budget_duration, set rpm/tpm limits. Attribution now exists at request time, not invoice time.
Set budgets that fail loud, not silent. Configure soft alerts at 60/80% and a hard cap at 100% per key. Decide per workload whether hitting the cap should degrade (fallback to a cheaper model) or stop — write that choice into the gateway config, and document it where the owning team will find it.
Instrument cost-per-request. Enable gateway spend logging and export to your observability stack (Langfuse for traces, or Prometheus metrics). Define the two SLI-like numbers that make LLM cost manageable: cost-per-request (p50/p95, per route) and tokens-per-request. Dashboards show them next to latency (TTFT/TPS) — cost regressions and latency regressions usually share a cause.
Alert on regressions, not just totals. A monthly budget alert catches disasters late. Add: cost-per-request p95 doubling over 24h baseline; tokens-per-request jump on a single route (prompt change or retry loop); spend rate that would exhaust the monthly budget in under a week. Use AI to draft these alert rules from your metric names, then review thresholds yourself.
Do the GPU side with utilization SLOs. From DCGM metrics, build the honest dashboard: allocation vs actual GPU utilization per namespace, cost per GPU-hour from OpenCost. Set a floor (e.g., "sustained <30% for 7 days triggers a review"), enable bin-packing improvements (time-slicing/MIG for small inference, Kueue for batch queueing), and route batch jobs to spot/preemptible pools.
Generate the monthly AI-cost narrative. Feed the gateway spend export and GPU utilization summary into the pb-27 workflow: per-team narrative, unit economics (cost per 1K requests, per feature), verified against the provider invoice. The gateway numbers and the invoice will disagree slightly — reconcile and document why (caching, retries, billing lag).
LLM cost control is a request-time problem — by the time it is a billing-console problem, the money is gone. The gateway is where budgets become enforceable.
An agentic workload without a per-key hard cap is an unbounded spend loop waiting for a bad prompt — cap first, then let it run.