Lago is an open-source, AI-native metering and usage-based billing platform (Ruby on Rails, AGPLv3, SOC 2 Type II). We self-hosted it on the client's cluster and wired event metering through to Stripe collection with a customer-facing usage dashboard.
A B2B AI SaaS startup with hybrid pricing — per-seat plus per-token usage — needed accurate billing without sending raw event data through a third-party vendor, for compliance reasons. Their old invoicing couldn't track real-time consumption, so credits were calculated by hand and disputed monthly.
- Self-hosting billing so no usage event data left the client's own infrastructure.
- Ingesting high-volume metered events from the client's LLM gateway without losing or double-counting usage.
- Modelling graduated, hybrid pricing and reconciling it cleanly into Stripe-collected invoices.
We deployed Lago on the client's GCP cluster (docker compose / Kubernetes), defined a tokens_consumed billable metric, instrumented their LLM gateway to emit events via POST /api/v1/events, assigned a graduated plan, and wired Lago → Stripe with a customer-facing usage dashboard.
- A self-hosted Lago deployment on the client's GCP cluster so all usage events stay inside their boundary.
- Event instrumentation posting {transaction_id, external_subscription_id, code:'tokens_consumed', properties:{value}} to Lago's ingestion endpoint in real time.
- A graduated pricing plan reconciled into Stripe, with an invoice.payment_succeeded webhook and a live customer usage dashboard.
A customized view of the system we shipped for this engagement — the components and how requests and data flow between them.
Before — manual bottleneck flow
Usage logs are gathered by hand at month-end with no real-time meter.
Hybrid charges are calculated in giant spreadsheets, introducing errors.
Customers contest hand-built invoices, triggering monthly back-and-forth.
After — automated optimized flow
Each token-consuming call posts a metered event to self-hosted Lago.
Events are rated against the graduated hybrid plan and roll into the live invoice.
Invoices are collected via Stripe and reflected on the customer usage dashboard.
“Billing per-token usage used to be a spreadsheet exercise at the end of every month. Now it meters in real time inside our own cloud, and the back-and-forth with customers over their invoices has mostly gone quiet.”

