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
# 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
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.