lago README

The project's README from github.com/getlago/lago. As one markdown file: README.md.

Lago product interfaces for billable metrics, real-time usage, alerts, invoices, credits, and pricing

Lago

Agentic-first monetization infrastructure for AI products
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.

Talk to us about Lago Cloud · Build with your AI agent · Run the AI billing demo · Documentation

GitHub stars Latest release AGPLv3 license Lago Slack community

Trusted by Mistral AI, Groq, PayPal, Synthesia, and Blacksmith. Lago issues $829 million in invoices each month.

“Lago has been able to follow the pace of our releases and has allowed us to focus on what we do best.”
Timothée Lacroix, CTO at Mistral AI · Read the customer story


Build with your AI agent

Give your coding agent Lago's public documentation, then choose the API, CLI, or MCP for your workflow. Paste this prompt to start:

Read https://getlago.com/llms.txt and follow the relevant Lago guides for this
project. Use https://swagger.getlago.com/openapi.yaml for exact API fields.
Help me design and implement a billing integration. Ask before live access.
Your task Start here
Build billing into your application REST API and SDKs
Inspect billing, run diagnostics, or write scripts Lago CLI
Give an assistant tools for live billing data and supported operations Lago MCP server
Give your agent current billing and API context Documentation index or documentation MCP

These interfaces work independently. Application code uses an SDK or the REST API; no Lago plugin is required. Confirm the target organization and environment, keep API keys out of prompts and source control, and review financial changes before execution.

Follow the agent setup guide for connection details and validation, or explore the website overview. To see real usage become a charge locally, run the maintained demo below.

See Lago price an AI workload

Run the maintained demo from this repository:

./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:

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:

./examples/agentic-ai-demo/run.sh --cleanup
Use Claude Code, Codex, or Cursor

Open this repository in your coding agent and paste:

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.

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.

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

Use Lago to launch and change pricing without rebuilding billing:

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

Lago Direct connects AI products, coding agents, and internal teams through APIs, Agent SDKs, the MCP server, and Lago UI. Lago Embedded lets platforms offer the same capabilities through APIs and white-label interfaces. Both use the Lago platform for metering, pricing, credits, entitlements, invoicing, payments, and revenue.

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 Direct Lago Embedded
Who monetizes You monetize your own product Your customers monetize through your platform
Experience Your application and teams use Lago through APIs, agent interfaces, and Lago UI Your customers use billing capabilities inside your product through APIs and white-label interfaces
Brand Lago powers your billing stack Lago stays behind the scenes under your brand
Public example Mistral AI PayPal

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.

Interface What it enables Availability
REST API and OpenAPI Program every core billing workflow and generate typed clients or tools from the schema Open source
Lago CLI Run billing commands, inspect structured output, and automate terminal workflows Open source, MIT
Lago MCP server Give an MCP-compatible agent tools to read and write invoices, usage, customers, payments, credit notes, coupons, and other Lago primitives Open source, MIT
Lago Agent SDK for Python Wrap supported LLM clients, normalize usage, and send token or model-cost events without blocking the LLM call Open source, MIT
Lago Agent SDK for JavaScript and TypeScript Instrument OpenAI, Anthropic, Mistral, Gemini, and AWS Bedrock clients with under 5 ms p99 wrapper overhead Open source, MIT
Finance Assistant Ask read-only questions about billing, usage, and revenue in plain language Available
Billing Assistant Query billing data and run operations in natural language, with confirmation for important or destructive actions Premium, 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

Layer Capabilities
Meter usage Real-time event ingestion, filters, dimensions, custom aggregations, batch ingestion, and idempotency by transaction_id
Model pricing Usage-based, recurring, prepaid, percentage, graduated, package, volume, minimum-commitment, and hybrid charges
Control access Entitlements, allowances, wallets, credit grants, top-ups, and usage alerts
Bill customers Subscriptions, invoices, credit notes, taxes, multiple currencies, multiple entities, and customer-specific overrides
Collect revenue Payment-provider orchestration, retries, dunning, and payment-status synchronization
Understand revenue Usage, MRR, invoice, customer, and revenue analytics
Connect the stack Salesforce, HubSpot, NetSuite, Xero, Avalara, cloud marketplaces, data warehouses, and webhooks
Lago Direct Meter and bill your own customers through Lago APIs, agent interfaces, and UI
Lago Embedded White-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

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.

Company Lago use Public company context
Mistral AI Token metering, prepaid credits, invoicing, taxes, and payment collection for paid AI products Reported at more than $400M in annualized revenue run rate
Groq Lago customer More than 5M developers and trillions of AI tokens processed weekly
Blacksmith Usage-based billing for compute-intensive CI workloads More than 6,000 companies; raised a $45M Series B at a $550M valuation
Synthesia Lago customer Approximately $140M ARR
PayPal Embedded, usage-based billing for merchants More than 430M active accounts worldwide

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

Deployment options

Lago Cloud and self-hosted Lago differ in deployment, not features. Your code uses the same API and SDKs either way; only the base URL changes.

With Lago Cloud, there is nothing to deploy or maintain. Lago runs and updates the platform for you in US or EU regions and provides commercial support, so your team never operates billing infrastructure. Talk to us about Lago Cloud.

2. Self-hosted and on-premise

Run the open-source platform from this repository (AGPLv3) in your cloud or on your own infrastructure when you need to inspect, extend, and operate billing yourself. Start with Deploy Lago below and the self-hosted deployment guide.

Also available

Option Best for Access
Agent tooling Teams that want to meter LLM usage or expose billing primitives to agents Separate open-source Agent SDK and MCP repositories, MIT
Premium capabilities Teams that need selected assistants, enterprise integrations, governance, or embedded use cases Availability varies by feature; talk to us

Deploy Lago

To self-host Lago or deploy it on-premise, start with a source-based local deployment:

[!WARNING] Upgrading an install that ran without these secrets? Do not run the block below as is: new encryption keys make the existing encrypted data unreadable. Read Secrets first.

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

# Generate the secrets once. A second run keeps the existing values.
touch .env
# The file holds secrets: only its owner can read it.
chmod 600 .env
# Add a final newline if the file has none: the lines below must not join the last line.
[ -n "$(tail -c1 .env)" ] && echo >> .env
grep -q '^LAGO_RSA_PRIVATE_KEY=.' .env || echo "LAGO_RSA_PRIVATE_KEY=\"$(openssl genrsa 2048 | openssl base64 -A)\"" >> .env
grep -q '^SECRET_KEY_BASE=.' .env || echo "SECRET_KEY_BASE=$(openssl rand -hex 64)" >> .env
for key in LAGO_ENCRYPTION_PRIMARY_KEY LAGO_ENCRYPTION_DETERMINISTIC_KEY LAGO_ENCRYPTION_KEY_DERIVATION_SALT; do
  grep -q "^${key}=." .env || echo "${key}=$(openssl rand -hex 32)" >> .env
done

docker compose up -d

[!IMPORTANT] Upgrading the front image. From v1.56.0 (getlago/lago-front#4359), the front container runs nginx as uid 65532 (not root), with a read-only root filesystem, and listens on 8080 (8443 for TLS) instead of 80 (443). The docker-compose.yml in this repository already maps the host ports to the new container ports. If you run your own Compose file, Kubernetes manifests or reverse proxy:

  • Point it at container port 8080. The host port can stay 80.
  • Give /tmp a writable mount (a tmpfs or an emptyDir). The container writes its pid file, env-config.js and csp.conf there.
  • If you mount your own nginx default.conf, listen on 8080/8443, and copy the env-config.js location, the dotfile location (it keeps /.env.sh private) and the include /tmp/csp.conf lines from extra/nginx-selfsigned.conf. Do not set ssl_dhparam: the image cannot load DH parameter files.
  • Make TLS keys readable by uid 65532 (extra/init-selfsigned.sh and extra/init-letsencrypt.sh do this).
  • Remove any command: override for the front service. It never reached nginx; use the entrypoint: in docker-compose.yml instead.

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

Language Client
Node.js lago-javascript-client
Python lago-python-client
Ruby lago-ruby-client
Go lago-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.

lago (getlago/lago)

Searching Database…

10.9K ·GitHub
What is this?Open-source metering and usage-based billing infrastructure: send usage events from your app, and Lago turns them into billable metrics, pricing, entitlements, invoices, and payments. Mistral AI, Groq, and PayPal use it publicly.
Is it a headless API, or does it have a UI too?Both: it's headless and API-first — REST API, SDKs, webhooks, and an MCP server for your code and agents — plus a web UI for finance, product, and ops teams when a human view is faster.
How do I get it running locally?Run the repo's Docker Compose demo — it needs Docker, curl, and jq (set LAGODEMOUIPORT/LAGODEMOAPIPORT if 8080 or 3001 are taken). For production, follow the self-hosted deployment guide or use the Helm charts.
How does my application send usage events to it?Through the REST API, using official SDK clients for Node.js, Python, Ruby, and Go; webhooks push billing events back to your systems.
Does it charge my customers' cards itself?No — Lago deliberately keeps metering and pricing separate from money movement: it orchestrates payment providers like Stripe, Adyen, or GoCardless, including retries and dunning, so you still need a payment provider.
Does a self-hosted instance send data back to Lago?Basic product analytics are collected by default, but no customer PII or financial data, and self-hosters can opt out.
Any licensing gotchas if I self-host it or build on it?The platform is AGPLv3 — copyleft that matters if you offer it to others as a service. The Agent SDKs and MCP server live in separate repositories under MIT.
What kinds of usage can it meter and bill?Anything you can emit as events: LLM tokens by model, input, output, cache, reasoning, or tool call; GPU, CPU, and storage consumption; API calls, transactions, seats, and custom events — plus prepaid credits with automatic top-ups and subscriptions with minimum commitments and overages.
What's the difference between Lago Direct and Lago Embedded?Direct is the standard mode: you meter and bill your own product's customers, like Mistral AI does. Embedded white-labels the same engine so platforms and marketplaces can offer billing inside their product under their own brand, like PayPal.
Can AI agents work with Lago directly?Yes, it's agentic-first: an MCP server gives agents read/write tools for invoices, usage, customers, and payments, and Agent SDKs for Python and JS/TS instrument OpenAI, Anthropic, Mistral, and Gemini clients with under 5 ms p99 wrapper overhead.
Is it production-ready for real scale?That's the design: idempotent ingestion deduplicated by transaction_id, atomic batches, isolatable async workers, Prometheus metrics, and SOC 2 Type II certification. Synthesia and Blacksmith run their billing on it publicly.
Creator
getlago
Size
153.3 MB
Stars
10.9K
Age
4y
Commits · 90 Days