1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →
How do you track and attribute LLM costs in an organisation?
30-second answerSay your answer out loud first, then reveal.
Implementation
- Gateway or SDK instrumentation: every call logs
{model, input_tokens, output_tokens, cached_tokens, feature, team, tenant, env}. - Price table: versioned (prices change), including discounts (batch, cached input, committed use).
- Aggregation: daily cost per feature, team and tenant; per-request distributions (to find outliers).
- Budgets and alerts: per team and feature; anomaly detection for sudden spikes (bugs, abuse, retry loops).
- Unit economics: cost per successful outcome; gross margin per customer tier for SaaS pricing.
- Showback / chargeback: monthly reports to team owners.
Self-hosted allocation: GPU cost per hour × hours ÷ tokens served gives cost per 1M tokens per model; idle capacity is shown as overhead, which motivates utilisation improvements.
Related
Slow is fine. Stopping is the only problem.