Lago: Open-Source Usage-Based Billing

Indie Hacker Newsgo watch the original →

Lago is an open-source, self-hosted alternative to Stripe Billing that handles metering, invoicing, and entitlements, specifically targeting AI companies and the agent economy.

Architecture and Core Functionality

Lago functions as a payment-agnostic billing engine that sits between your application and payment processors like Stripe or Adyen. It manages the billing logic, metering, and invoicing while leaving the actual payment processing to external providers. The core stack is built on a Ruby on Rails API, utilizing Sidekiq with Redis for background jobs and a separate Go-based service to ingest high-volume usage events. Data persistence is split between PostgreSQL for core billing records and ClickHouse for high-speed aggregation of raw usage events.

AI and Agent Integration

Lago is positioning itself as the billing layer for AI agents by providing an Agent SDK and an MCP server. The Agent SDK allows developers to wrap LLM clients to meter token usage across multiple dimensions with single-digit millisecond latency. Additionally, the platform includes a Stripe shared payment token feature, enabling AI agents to process invoices and handle payment fallbacks without human intervention.

Operational Considerations

Deployment is handled via a single docker-compose configuration. While the platform provides pre-built templates for common pricing models used by companies like Algolia and Segment, self-hosting requires the user to assume full responsibility for the uptime and accuracy of the billing engine. Because the platform is AGPL-licensed and mission-critical, users must weigh the cost of infrastructure management against the recurring percentage-based fees charged by managed alternatives like Metronome or Orb.

  • #dev-tooling
  • #saas
  • #billing

summary by google/gemini-3.1-flash-lite. probably wrong about something. check the source.