# 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. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash git clone https://github.com/getlago/lago.git cd lago docker compose up -d ``` Open `http://localhost:80` — access the Lago dashboard to configure billing plans and meters. ## Intro **Lago** is an open-source billing API for usage-based pricing models. It handles metering, subscription management, invoicing, and payment orchestration — replacing expensive SaaS billing platforms like Stripe Billing, Chargebee, or Zuora for companies that need flexibility and control. With 9.5K+ GitHub stars and AGPL-3.0 license, Lago powers billing for AI companies, API platforms, and SaaS products that charge based on consumption (API calls, tokens, compute hours, storage). ## What Lago Does Lago provides the complete billing infrastructure: - **Usage Metering**: Ingest events via API, aggregate by count, sum, max, unique count, or weighted sum - **Flexible Pricing**: Per-unit, graduated, package, percentage, and volume-based pricing models - **Subscription Management**: Create plans with recurring charges, add-ons, and trial periods - **Real-Time Invoicing**: Automatic invoice generation with PDF export and tax calculation - **Payment Orchestration**: Integrate with Stripe, GoCardless, Adyen for automatic payment collection - **Revenue Analytics**: Track MRR, churn, lifetime value, and usage trends - **Webhooks**: Real-time events for invoice created, payment succeeded/failed, subscription changes - **Multi-Currency**: Support for 150+ currencies with automatic conversion ### Ingesting Usage Events ```bash # Send a usage event via API curl -X POST https://api.lago.dev/api/v1/events \ -H "Authorization: Bearer $LAGO_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"event\": { \"transaction_id\": \"tx_001\", \"external_subscription_id\": \"sub_123\", \"code\": \"api_calls\", \"timestamp\": $(date +%s), \"properties\": { \"tokens\": 1500 } } }" ``` ### Python SDK ```python from lago_python_client import Client client = Client(api_key="lago_api_key") # Create a billable metric client.billable_metrics.create({ "name": "API Calls", "code": "api_calls", "aggregation_type": "sum_agg", "field_name": "tokens" }) # Create a plan with usage-based pricing client.plans.create({ "name": "Pro Plan", "code": "pro", "interval": "monthly", "amount_cents": 4900, "charges": [{ "billable_metric_code": "api_calls", "charge_model": "graduated", "properties": { "graduated_ranges": [ {"from_value": 0, "to_value": 10000, "per_unit_amount": "0.001"}, {"from_value": 10001, "to_value": None, "per_unit_amount": "0.0005"} ] } }] }) ``` ## FAQ **Q: Is Lago suitable for AI/LLM billing?** A: Yes. Lago is specifically designed for usage-based billing — track tokens, API calls, compute hours, or any custom metric and bill accordingly. **Q: How does Lago compare to Stripe Billing?** A: Lago offers more flexible metering and pricing models, full self-hosting, and no percentage-of-revenue fees. Stripe Billing is easier to start with but less customizable for complex usage-based models. **Q: Can I self-host Lago?** A: Yes. Deploy with Docker Compose for a complete setup including PostgreSQL, Redis, and the web dashboard. **Q: What payment processors does Lago support?** A: Stripe, GoCardless, and Adyen. Payment collection is automatic based on generated invoices. ## Source & Thanks - GitHub: [getlago/lago](https://github.com/getlago/lago) — 9.5K+ ⭐ | AGPL-3.0 - Website: [getlago.com](https://www.getlago.com) - Docs: [docs.getlago.com](https://docs.getlago.com) ## Quick Use ```bash git clone https://github.com/getlago/lago.git cd lago docker compose up -d ``` Open `http://localhost:80` to access the Lago dashboard and configure billing plans and meters. ## Introduction **Lago** is an open-source billing API designed for usage-based pricing. It handles metering, subscription management, invoicing, and payment orchestration — replacing expensive SaaS billing platforms like Stripe Billing and Chargebee. With 9.5K+ GitHub stars and AGPL-3.0 licensing, Lago provides the billing infrastructure for AI companies, API platforms, and consumption-based SaaS products. ## Core Features - **Usage metering**: Ingest events via API with count, sum, max, and other aggregation modes - **Flexible pricing**: Per-unit, tiered, package, percentage, and usage-based pricing models - **Subscription management**: Create plans with recurring fees, add-ons, and trial periods - **Real-time invoicing**: Auto-generated invoices with PDF export and tax calculation - **Payment orchestration**: Automated collection via Stripe, GoCardless, and Adyen ## FAQ **Q: Is Lago suitable for AI/LLM billing?** A: Yes. Lago is built for usage-based billing and can track tokens, API calls, compute time, or any custom metric. **Q: Can I self-host?** A: Yes. Deploy with Docker Compose, including PostgreSQL, Redis, and the web dashboard. ## Source & Thanks - GitHub: [getlago/lago](https://github.com/getlago/lago) — 9.5K+ ⭐ | AGPL-3.0 - Website: [getlago.com](https://www.getlago.com) --- Source: https://tokrepo.com/en/workflows/lago-open-source-usage-based-billing-api-f9227c2e Author: AI Open Source