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.
Safe staging for this asset
This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.
npx -y tokrepo@latest install f9227c2e-3474-11f1-9bc6-00163e2b0d79 --target codexStages files first; activation requires review of the staged README and plan.
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
Ghostfolio — Open Source Wealth Management & Portfolio Tracker
Ghostfolio is an open-source personal finance dashboard for tracking stocks, ETFs, crypto, and other investments with real-time market data and performance analytics.
Huly — All-in-One Open Source Project Management Platform
Huly is an open-source alternative to Linear, Jira, Slack, and Notion. Project tracking, team chat, knowledge base, and HR tools in a single unified platform.
Keycloak — Open Source Identity & Access Management
Keycloak is the most widely deployed open-source IAM solution. SSO, OIDC, SAML, LDAP federation, MFA, social login, and user management for enterprise applications.
Bruno — Open-Source IDE for API Exploration & Testing
Bruno is an open-source IDE for exploring and testing APIs — a lightweight, offline-first alternative to Postman and Insomnia. Stores collections as plain text files in your filesystem so they version-control naturally with Git.