Lago — Open Source Usage-Based Billing API
Lago is an open-source metering and billing engine for usage-based pricing, subscription management, invoicing, and payment orchestration.
What it is
Lago is an open-source billing API designed for usage-based pricing models. It handles event ingestion, metering, subscription management, invoice generation, and payment orchestration. The project is licensed under AGPL-3.0.
Lago targets SaaS companies, API platforms, and AI services that charge based on consumption -- API calls, tokens, compute hours, or storage. It replaces proprietary billing platforms like Stripe Billing, Chargebee, or Zuora for teams that need full control over their billing logic.
How it saves time or tokens
Lago provides a complete billing pipeline out of the box. Instead of building metering, aggregation, proration, and invoice rendering from scratch, you configure billing plans and meters through the dashboard or API. Events are ingested via a simple HTTP endpoint, and Lago handles the rest.
The self-hosted deployment means you avoid per-transaction fees from managed billing platforms, which matters at scale for high-volume usage-based models.
How to use
- Clone the repository and start with Docker Compose:
git clone https://github.com/getlago/lago.git && cd lago && docker compose up -d. - Open the dashboard at
http://localhost:80and configure your billing plans, meters, and pricing tiers. - Ingest usage events from your application via the REST API and let Lago generate invoices automatically.
Example
# Start Lago
git clone https://github.com/getlago/lago.git
cd lago
docker compose up -d
# Ingest a usage event
curl -X POST http://localhost:3000/api/v1/events \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"event": {
"transaction_id": "txn_001",
"external_customer_id": "customer_123",
"code": "api_calls",
"timestamp": 1700000000,
"properties": {"tokens": 1500}
}
}'
Related on TokRepo
- API tools -- Tools for building and managing APIs
- Self-hosted tools -- Self-hostable infrastructure for development teams
Common pitfalls
- Lago uses AGPL-3.0 licensing. If you modify the source and serve it as a SaaS, you must open-source your changes. Review the license before deploying in proprietary environments.
- The Docker Compose setup requires PostgreSQL and Redis. Ensure both services have adequate resources for production workloads with high event volumes.
- Invoice PDF generation depends on a separate service. If you need custom invoice templates, you must configure the PDF rendering component separately.
Frequently Asked Questions
Lago is open-source and self-hostable, giving you full control over billing logic and data. Stripe Billing is a managed service with simpler setup but charges per-transaction fees and limits customization. Lago is better suited for complex usage-based models where you need custom metering rules.
Lago supports flat-rate subscriptions, usage-based pricing with configurable aggregation (sum, count, max, unique count), tiered pricing, volume pricing, graduated pricing, and percentage-based pricing. You can combine multiple billable metrics in a single plan.
Yes. Lago uses an event queue backed by Redis for ingestion and processes events asynchronously. For very high volumes, you can scale the worker processes horizontally. The metering engine aggregates events efficiently using PostgreSQL.
Lago integrates with Stripe, GoCardless, and Adyen for payment collection. It generates invoices and can trigger automatic payment attempts through these processors. You can also use Lago for invoicing only and handle payments separately.
Yes. Lago offers a cloud-hosted version at getlago.com with managed infrastructure, support, and additional enterprise features. The self-hosted open-source version has the same core billing engine.
Citations (3)
- Lago GitHub— Lago is an open-source billing API for usage-based pricing
- Lago Documentation— AGPL-3.0 licensed metering and billing engine
- Lago Payment Integrations— Integrates with Stripe, GoCardless, and Adyen for payments
Related on TokRepo
Source & Thanks
- GitHub: getlago/lago — 9.5K+ ⭐ | AGPL-3.0
- Website: getlago.com
- Docs: docs.getlago.com
Discussion
Related Assets
DTM — Distributed Transaction Manager for Microservices
A cross-language distributed transaction framework supporting Saga, TCC, XA, and two-phase message patterns for reliable microservice coordination.
WatermelonDB — Reactive Database for React Native Apps
A high-performance reactive database framework for React Native and React web apps, built on top of SQLite with lazy loading and sync primitives.
Dexie.js — Minimalist IndexedDB Wrapper for the Web
A lightweight wrapper around IndexedDB that provides a clean Promise-based API for client-side storage in web applications.