Back to Lago

README

README.md

1.52.015.9 KB
Original Source
<!-- PROJECT LOGO --> <div align="center"> <a href="https://github.com/getlago/lago"> </a> <h1 align="center">Lago</h1> <p> <strong>Agentic-first, open-source monetization infrastructure for AI products</strong>
Meter tokens, compute, API calls, or any product usage.

Turn usage into pricing, credits, entitlements, invoices, payments, and revenue.


Use Lago Direct for your own product, or Lago Embedded to power monetization for your customers.




<a href="#see-lago-price-an-ai-workload"><strong>Run the AI billing demo</strong></a>
·
<a href="https://doc.getlago.com"><strong>Documentation</strong></a>
·
<a href="https://www.getlago.com/pricing"><strong>Talk to us about Lago Cloud</strong></a>
</p> </div> <p align="center"> <a href="https://github.com/getlago/lago/stargazers"></a> <a href="https://github.com/getlago/lago/releases"></a> <a href="https://github.com/getlago/lago/blob/main/LICENSE"></a> <a href="https://www.getlago.com/slack"></a> </p> <p align="center"> </p> <p align="center"> <em>“Lago has been able to follow the pace of our releases and has allowed us to focus on what we do best.”</em>

<strong>Timothée Lacroix, CTO at Mistral AI</strong> · <a href="https://getlago.com/blog/mistral-billing">Read the customer story</a>

</p>

See Lago price an AI workload

Run the maintained demo from this repository:

bash
./examples/agentic-ai-demo/run.sh

It starts the Lago version that matches this checkout, creates a disposable local organization, and prices three illustrative AI requests. Each request sends one input-token event and one output-token event:

text
3 AI requests
5,000 input tokens  x $0.000002 = $0.01
1,250 output tokens x $0.000008 = $0.01
Lago usage total                   = $0.02

Docker Compose starts an isolated Lago service, then a small script seeds and verifies the example through Lago's API. It retrieves current usage, independently reconciles the result, and retries one transaction to confirm that usage does not increase. Everything stays on your machine; the demo does not access Lago Cloud. The bundled credentials and API key are disposable and only intended for this local demo.

Log into http://localhost:8080 with [email protected] / agentic-ai-demo-local-password, then open Customers → Agentic AI Demo Customer → Agentic AI Demo subscription → Usage.

Requirements: Docker, curl, and jq. If ports 8080 or 3001 are occupied, set LAGO_DEMO_UI_PORT and LAGO_DEMO_API_PORT before running. The demo keeps Lago running so you can inspect the customer, metrics, plan, subscription, events, and usage in the UI. Remove its isolated Compose project and data volume when you are done:

bash
./examples/agentic-ai-demo/run.sh --cleanup
<details> <summary><strong>Use Claude Code, Codex, or Cursor</strong></summary>

Open this repository in your coding agent and paste:

text
Run Lago's maintained Agentic AI demo by following this README. Keep it local;
do not modify source files or unrelated Docker resources. When it passes, give
me the UI URL, token usage and charges, idempotency evidence, and cleanup
command. Then offer to connect this agent to Lago's local MCP server.
</details>

What is Lago?

Lago is the programmable system between product usage and revenue. Send events from your application, turn them into billable metrics, apply pricing and entitlements, then generate invoices and collect payments.

text
Usage events -> Metering -> Pricing and credits -> Entitlements -> Invoices -> Payments -> Revenue

Use Lago to launch and change pricing without rebuilding billing:

  • tokens by model, input, output, cache, reasoning, or tool call
  • GPU, CPU, storage, and other compute consumption
  • API calls, transactions, seats, active users, or custom events
  • prepaid credits with automatic top-ups
  • subscriptions with allowances, minimum commitments, and overages
  • self-serve plans and negotiated enterprise contracts in the same system

Lago is headless and API-first. Your application, internal tools, and agents use the same billing primitives through the REST API, SDKs, webhooks, and MCP server. Product, finance, and operations teams can use the Lago UI when a human interface is faster.

How Lago fits into your stack

<p align="center"> </p>

Lago keeps metering and pricing independent from payment processing. Connect Stripe, Adyen, GoCardless, or another provider without making its product catalog your source of truth.

Lago Direct and Lago Embedded

The same Lago engine supports two operating models:

Lago DirectLago Embedded
Who monetizesYou monetize your own productYour customers monetize through your platform
ExperienceYour application and teams use Lago through APIs, agent interfaces, and Lago UIYour customers use billing capabilities inside your product through APIs and white-label interfaces
BrandLago powers your billing stackLago stays behind the scenes under your brand
Public exampleMistral AIPayPal

Lago Direct is the standard way to use Lago: send your own product usage, model your pricing, and bill your customers. Lago Embedded uses the same primitives to let platforms, marketplaces, AI builders, fintech products, and developer tools offer metering and billing to their customers.

Both models start with Lago's open-source billing engine and can be paired with Premium deployment, customization, security, and support options. With Lago Embedded, you control the customer experience and which capabilities your users can access.

Agentic-first by design

Agentic-first means Lago's billing model is available as structured, inspectable interfaces instead of being trapped in a dashboard.

InterfaceWhat it enablesAvailability
REST API and OpenAPIProgram every core billing workflow and generate typed clients or tools from the schemaOpen source
Lago MCP serverGive an MCP-compatible agent tools to read and write invoices, usage, customers, payments, credit notes, coupons, and other Lago primitivesOpen source, MIT
Lago Agent SDK for PythonWrap supported LLM clients, normalize usage, and send token or model-cost events without blocking the LLM callOpen source, MIT
Lago Agent SDK for JavaScript and TypeScriptInstrument OpenAI, Anthropic, Mistral, Gemini, and AWS Bedrock clients with under 5 ms p99 wrapper overheadOpen source, MIT
Finance AssistantAsk read-only questions about billing, usage, and revenue in plain languageBeta, early access
Billing AssistantQuery billing data and run operations in natural language, with confirmation for important or destructive actionsPremium beta, available upon request

The MCP server exposes read and write tools and inherits the permissions of its Lago API key. Treat agent credentials as privileged, control who can access the agent, review tool calls, and keep human confirmation around sensitive billing changes.

Platform

LayerCapabilities
Meter usageReal-time event ingestion, filters, dimensions, custom aggregations, batch ingestion, and idempotency by transaction_id
Model pricingUsage-based, recurring, prepaid, percentage, graduated, package, volume, minimum-commitment, and hybrid charges
Control accessEntitlements, allowances, wallets, credit grants, top-ups, and usage alerts
Bill customersSubscriptions, invoices, credit notes, taxes, multiple currencies, multiple entities, and customer-specific overrides
Collect revenuePayment-provider orchestration, retries, dunning, and payment-status synchronization
Understand revenueUsage, MRR, invoice, customer, and revenue analytics
Connect the stackSalesforce, HubSpot, NetSuite, Xero, Avalara, cloud marketplaces, data warehouses, and webhooks
Lago DirectMeter and bill your own customers through Lago APIs, agent interfaces, and UI
Lago EmbeddedWhite-label metering and billing for platforms, marketplaces, AI builders, and fintech products

Explore metering, billing and invoicing, entitlements, cash collection, revenue analytics, and integrations.

Production characteristics

  • Idempotent ingestion. Lago deduplicates usage events by transaction_id, so retrying an event does not bill it twice. Read the ingestion guide.
  • Atomic batches. If one event in a batch is invalid, Lago rejects the batch and persists none of its events. Read the batch API reference.
  • Asynchronous processing. Dedicated workers can isolate events, billing, payments, invoices, webhooks, PDFs, alerts, and analytics as volume grows. Review the architecture.
  • Observable operation. Lago exposes Prometheus metrics for APIs, queues, workers, events, billing, webhooks, and dependencies. Review monitoring.
  • Deployment control. Run Lago locally, in your cloud, or on your infrastructure. Production deployments can separate and scale stateful services and workers independently.
  • Security. Lago is SOC 2 Type II certified and supports self-hosting for teams that need infrastructure and data control. Review security.

Chosen by teams operating at scale

Mistral AI, Groq, PayPal, Synthesia, Blacksmith, and other teams have publicly selected Lago for billing. The figures below describe the companies using Lago, not volume processed by Lago.

CompanyLago usePublic company context
Mistral AIToken metering, prepaid credits, invoicing, taxes, and payment collection for paid AI productsReported at more than $400M in annualized revenue run rate
GroqLago customerMore than 5M developers and trillions of AI tokens processed weekly
BlacksmithUsage-based billing for compute-intensive CI workloadsMore than 6,000 companies; raised a $45M Series B at a $550M valuation
SynthesiaLago customerApproximately $140M ARR
PayPalEmbedded, usage-based billing for merchantsMore than 430M active accounts worldwide

Sources for company context: Mistral AI, Groq, Blacksmith, Synthesia, and PayPal.

Open source and managed options

OptionBest forAccess
Lago open sourceTeams that want to inspect, extend, and operate the billing platform on their infrastructureThis repository, AGPLv3
Agent toolingTeams that want to meter LLM usage or expose billing primitives to agentsSeparate open-source Agent SDK and MCP repositories, MIT
Lago CloudTeams that want Lago to operate the platform and provide commercial supportTalk to us
Premium capabilitiesTeams that need selected assistants, enterprise integrations, governance, or embedded use casesAvailability varies by feature; talk to us

Deploy Lago

For a source-based local deployment:

bash
git clone --depth 1 https://github.com/getlago/lago.git
cd lago

echo "LAGO_RSA_PRIVATE_KEY=\"$(openssl genrsa 2048 | openssl base64 -A)\"" >> .env
docker compose up -d

Use the self-hosted deployment guide for persistent storage, SMTP, TLS, object storage, Redis, database configuration, and upgrades. For larger deployments, use the Lago Helm charts and configure dedicated workers.

SDKs and developer resources

LanguageClient
Node.jslago-javascript-client
Pythonlago-python-client
Rubylago-ruby-client
Golago-go-client

Contributing

Lago is built in the open. Read the contributing guide and development environment setup to get started.

Look for issues labeled beginner or help-wanted, or join the Lago Slack community.

License

The Lago platform is distributed under the AGPLv3 license. Read why Lago chose AGPLv3. Lago's Agent SDKs and MCP server are distributed from separate repositories under the MIT license.

Analytics and tracking

Self-hosted Lago instances collect basic product analytics by default. Lago does not collect customer PII or financial data through this tracking. Review what is collected or opt out.