DEV Community

Alfred M
Alfred M

Posted on

Per-Customer Cost Tracking for LLM SaaS: Know Your Margins Before They Disappear

Per-Customer Cost Tracking for LLM SaaS: Know Your Margins Before They Disappear

If you are building a SaaS product on top of LLMs or third-party APIs, your costs are not fixed. What you might not know is which customers are responsible for the expensive ones.

The Problem

Most small teams have a rough idea of their total API costs. Fewer have visibility into per-customer margins. Your API provider dashboard and Stripe do not talk to each other, and neither answers the question you actually need: what did it cost me to serve customer X this billing period, by feature?

Without that number, usage-based pricing is guesswork.

Why Existing Tools Fall Short

OpenMeter and Lago are solid open-source metered billing tools, but they are designed to bill outward to customers and require infrastructure like Kafka and ClickHouse that is hard to justify for a small team.

Stripe tells you revenue per customer. It cannot tell you margin per customer.

What Per-Customer Attribution Looks Like

  1. Every API call is tagged with a customer ID and a feature name
  2. You define cost rules per feature, for example 0.01 USD per 1000 tokens for GPT-4o
  3. Costs accumulate in real time giving you live margin per customer and per feature
  4. Alerts fire when a customer crosses a cost threshold before the billing cycle ends

UsageMeter is built around this model. A REST API and TypeScript SDK, a few hours to integrate, no infrastructure to babysit. 29 GBP per month.

If you have never verified your pricing actually covers your costs per customer, it is worth finding out before you subsidise someone for six months without realising it.

Top comments (0)