PromptHub
Back to Blog
Developer Tools Open Source

getlago/lago: Open-Source Billing for Usage-Based Revenue

B

Bright Coding

Author

9 min read 44 views
getlago/lago: Open-Source Billing for Usage-Based Revenue

getlago/lago: Open-Source Billing for Usage-Based Revenue

Building billing infrastructure that handles metering, pricing iterations, and payment orchestration is one of the most underestimated engineering challenges in product-led growth. Most teams start with simple subscriptions, then discover they need event ingestion, usage aggregation, entitlements, multi-gateway payments, and revenue analytics—each layer adding months of internal development. getlago/lago addresses this directly: an open-source, API-first billing platform with 10,216 GitHub stars, built in Go, and licensed under AGPLv3.

What is getlago/lago?

getlago/lago is an open-source metering and usage-based billing API. The project describes itself as "the AI-native billing platform" and provides infrastructure for consumption tracking, subscription management, pricing iterations, payment orchestration, and revenue analytics. It is maintained by Lago, a Y Combinator-backed company, and has accumulated 696 forks with its most recent commit dated July 14, 2026.

The platform occupies a specific technical category: billing and revenue infrastructure positioned between raw payment processors (Stripe, Adyen) and financial ERP systems (NetSuite, Xero). Unlike closed-source alternatives, Lago offers full code transparency with self-hosted deployment for data control, plus a managed cloud option for faster time-to-market. The Go-based architecture suggests performance-conscious design for high-volume event ingestion—critical for real-time usage metering.

Lago's relevance now stems from the industry shift toward usage-based pricing in AI, infrastructure, and API-first products. Companies like Mistral AI, Groq, and Synthesia (all listed as customers) operate models where traditional flat subscriptions fail. The platform's "AI-native" positioning, including an MCP server for AI agents, indicates forward-looking integration with automated billing workflows.

The AGPLv3 license is a deliberate choice—documented in Lago's own blog post on open-source licensing—ensuring derivative works remain open while allowing commercial usage. This matters for teams evaluating vendor lock-in versus community contribution obligations.

Key Features

Lago's feature set spans the full billing lifecycle:

Usage Metering ingests and aggregates events in real-time for any pricing dimension. This is foundational for usage-based models—without accurate metering, billing accuracy collapses.

Billing & Invoicing automates invoice generation across subscriptions, usage, and hybrid plans. The system handles the complexity of mixed pricing models that pure subscription or pure usage tools cannot.

Entitlements connect feature access directly to billing plans. This tight coupling prevents the common drift between what customers pay for and what they can actually access.

Cash Collection provides payment orchestration with dunning management, retry logic, and multi-gateway support (Stripe, Adyen, GoCardless, or custom integrations). This abstraction layer reduces direct dependency on any single payment provider.

Revenue Analytics offers cross-stream visibility into MRR, usage trends, and revenue drivers. For finance and growth teams, this replaces spreadsheet-heavy reconciliation processes.

Lago Embedded enables white-label billing for platforms and marketplaces—relevant for B2B infrastructure companies reselling services.

Lago AI adds AI-powered billing intelligence and an MCP (Model Context Protocol) server for AI agents, reflecting the project's stated "AI-native" direction.

Integrations extend to accounting (NetSuite, Xero), CRM (Salesforce, HubSpot), tax (Avalara), and cloud marketplaces (AWS↗ Bright Coding Blog, Azure, GCP).

SOC 2 Type II certification addresses enterprise security requirements, a common procurement blocker for billing infrastructure.

Use Cases

AI/ML API Pricing: Companies offering inference APIs—like Mistral AI and Groq—need per-token or per-request billing with real-time metering. Lago's event ingestion and aggregation supports granular usage dimensions without custom pipeline development.

SaaS with Hybrid Pricing: Products combining base subscriptions with overage charges (common in infrastructure, data, and devtools) require unified invoice generation across both models. Lago's hybrid plan support prevents the architectural split of maintaining two separate billing systems.

Platform/Marketplace Billing: Companies enabling third-party transactions can use Lago Embedded to offer white-label billing, controlling the customer experience while outsourcing infrastructure complexity.

Usage-Based Feature Entitlements: Teams selling tiered access to features (e.g., API rate limits, storage quotas, compute allocations) can tie entitlements directly to billing plans, ensuring automated enforcement of contractual limits.

Multi-Gateway Payment Operations: Organizations operating in multiple geographies with different preferred payment methods can orchestrate across Stripe, Adyen, and GoCardless from a single system, reducing operational fragmentation.

Installation & Setup

Lago offers two deployment paths: managed cloud (fastest) or self-hosted (full data control).

Cloud Deployment

Sign up at Lago Cloud or contact hello@getlago.com. No infrastructure management required.

Self-Hosted Requirements

Quick Start Commands

# Clone the repository
git clone --depth 1 https://github.com/getlago/lago.git
cd lago

# Generate RSA key for API authentication
echo "LAGO_RSA_PRIVATE_KEY=\"$(openssl genrsa 2048 | openssl base64 -A)\"" >> .env
source .env

# Start all services
docker compose up

After startup, the UI is available at http://localhost and the API at http://localhost:3000.

Post-Update Procedure

docker compose up

The update process is intentionally simple—no database migration commands or version pinning shown in the README.

Network Configuration

For non-localhost deployments, set these environment variables in .env:

LAGO_API_URL="http://your-server:3000"
LAGO_FRONT_URL="http://your-server"

The README notes that advanced configuration—including S3/GCS storage, SMTP, SSL, and dedicated workers for high-volume scenarios—is documented in the self-hosted guide.

API Key Retrieval

  1. Open the Developer section in the sidebar
  2. Navigate to the API keys tab
  3. Click Copy

Real Code Examples

The README provides one explicit code block: the Docker Compose startup sequence. Below is the complete self-hosted setup with explanatory comments.

Repository Clone and Environment Setup:

# Shallow clone to reduce download size; sufficient for deployment
git clone --depth 1 https://github.com/getlago/lago.git
cd lago

# Generate 2048-bit RSA key, base64-encode for single-line env var storage
# This key secures API authentication between services
echo "LAGO_RSA_PRIVATE_KEY=\"$(openssl genrsa 2048 | openssl base64 -A)\"" >> .env

# Load environment variables into current shell session
source .env

The --depth 1 flag minimizes repository history; acceptable for production deployment but developers contributing to Lago should use full clones. The RSA key generation uses standard OpenSSL tooling—no proprietary dependencies.

Service Startup:

# Pull images and start containers in foreground
docker compose up

# For detached production operation, add -d flag (implied by Docker Compose conventions)

The README does not specify -d (detached mode), suggesting the documented quick start is intended for initial verification rather than production daemonization.

Post-Configuration URL Setup:

# Example .env additions for remote server deployment
LAGO_API_URL="http://your-server:3000"    # Backend API endpoint
LAGO_FRONT_URL="http://your-server"        # Frontend/UI endpoint

The README contains no additional code examples for API usage, SDK integration, or event ingestion. The [INTERNAL_LINK: API client libraries] section below references external repositories for language-specific implementations.

Advanced Usage & Best Practices

Based on Lago's documented architecture and design decisions:

Event Ingestion at Scale: The Go-based backend and dedicated worker configuration option suggest horizontal scaling for high-volume metering. Teams should monitor the monitoring documentation for Prometheus metrics and establish alerting before production load.

License Compliance: AGPLv3 requires source disclosure for network-deployed modifications. Teams customizing Lago should review the licensing explanation and consult legal counsel on distribution obligations.

Payment Gateway Abstraction: The multi-gateway support reduces vendor concentration risk, but introduces reconciliation complexity. Maintain clear audit trails across Stripe, Adyen, and GoCardless reporting.

Analytics Opt-Out: Self-hosted instances track basic actions by default. Review the tracking documentation to understand collected data and opt-out procedures if required by internal policies.

Development Environment: Contributors should follow the development environment setup rather than the Docker quick start, which is optimized for deployment.

Comparison with Alternatives

Dimension getlago/lago Stripe Billing Chargebee
License AGPLv3 (open source) Proprietary Proprietary
Self-Hosting Full control via Docker Not available Limited enterprise option
Pricing Model Support Usage, subscription, hybrid Strong subscription; usage via Stripe Meter Subscription-focused; usage add-on
Payment Gateways Multi-gateway (Stripe, Adyen, GoCardless, custom) Stripe-native; limited others Multiple supported
AI/Agent Integration MCP server for AI agents Emerging Not documented
Revenue Analytics Built-in cross-stream Stripe Sigma (separate) Built-in

Lago's open-source model trades vendor convenience for infrastructure control. Stripe Billing offers tighter payment integration but locks into Stripe's ecosystem. Chargebee provides mature subscription management with less native usage-based depth. Teams prioritizing code transparency, hybrid pricing flexibility, or multi-gateway independence should evaluate Lago; those seeking fastest time-to-market with single-gateway simplicity may prefer managed alternatives.

FAQ

What license does getlago/lago use? AGPLv3. Modifications deployed over a network require source disclosure.

Can I self-host Lago for free? Yes. The open-source code is freely available; Lago Cloud is the paid managed option.

What backend language is Lago built in? Go, with 10,216 GitHub stars and 696 forks as of the latest commit.

Does Lago work without Stripe? Yes. It supports Adyen, GoCardless, and custom payment gateways.

Is customer data tracked in self-hosted deployments? Basic actions are tracked by default; no PII or financial data. Opt-out is documented.

How do I contribute to Lago? See the contributing guide and issues labeled beginner or help-wanted.

What is the MCP server mentioned in Lago AI? A Model Context Protocol server enabling AI agents to interact with billing operations programmatically.

Conclusion

getlago/lago fills a specific gap in developer infrastructure: open-source, API-first billing for complex pricing models that outgrow simple subscriptions. With 10,216 stars, active maintenance, and backing from Y Combinator, it has demonstrated traction beyond experimental status. The Go-based architecture, multi-gateway support, and SOC 2 certification make it suitable for teams with compliance requirements and high-volume metering needs.

It is best suited for: product-led companies implementing usage-based or hybrid pricing; platforms requiring white-label billing; and teams prioritizing infrastructure control over vendor convenience.

It is less suited for: teams needing immediate managed simplicity with minimal setup; or those unwilling to operate AGPLv3 compliance.

Explore the repository, review the architecture documentation, and evaluate against your pricing complexity at https://github.com/getlago/lago.

SDKs & Client Libraries

Language Package
Node.js javascript↗ Bright Coding Blog-client">lago-javascript-client
Python↗ Bright Coding Blog lago-python-client
Ruby lago-ruby-client
Go lago-go-client

Full OpenAPI specification: lago-openapi

Comments (0)

Comments are moderated before appearing.

No comments yet. Be the first to share your thoughts!

Recommended Prompts

View All