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, open-source 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.

Run the AI billing demo · Documentation · Talk to us about Lago Cloud

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


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 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 Beta, early access
Billing Assistant Query billing data and run operations in natural language, with confirmation for important or destructive actions Premium 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

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.

Open source and managed options

Option Best for Access
Lago open source Teams that want to inspect, extend, and operate the billing platform on their infrastructure This repository, AGPLv3
Agent tooling Teams that want to meter LLM usage or expose billing primitives to agents Separate open-source Agent SDK and MCP repositories, MIT
Lago Cloud Teams that want Lago to operate the platform and provide commercial support Talk to us
Premium capabilities Teams that need selected assistants, enterprise integrations, governance, or embedded use cases Availability varies by feature; talk to us

Deploy Lago

For a source-based local deployment:

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

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.7K ·GitHub
这是什么?开源的用量计量和按用量计费基础设施:从你的应用发送用量事件,Lago 会把它们转换成可计费指标、定价、权益、发票和收款。Mistral AI、Groq 和 PayPal 都在公开使用它。
它是无界面的 API,还是也有图形界面?两者都有:它是无界面、API 优先的——提供 REST API、SDK、webhook,以及供你的代码和智能体使用的 MCP 服务器——此外还有一个 Web 界面,方便财务、产品和运营团队在需要人工查看时更快上手。
我如何在本地把它跑起来?运行仓库里的 Docker Compose 演示——它需要 Docker、curl 和 jq(如果 8080 或 3001 端口被占用,可以设置 LAGODEMOUIPORT/LAGODEMOAPIPORT)。生产环境请按照自托管部署指南操作,或使用 Helm charts。
我的应用怎么把用量事件发送给它?通过 REST API,使用官方提供的 Node.js、Python、Ruby 和 Go SDK 客户端;webhook 会把计费事件推送回你的系统。
它会替我向客户的银行卡收费吗?不会——Lago 刻意把计量和定价与资金流转分开:它负责调度 Stripe、Adyen 或 GoCardless 这类支付服务商,包括重试和催收,所以你仍然需要一个支付服务商。
自托管的实例会把数据回传给 Lago 吗?默认会收集基础的产品分析数据,但不包含客户的个人身份信息或财务数据,自托管用户可以选择关闭。
如果我自托管或基于它做开发,许可证方面有什么要注意的?平台采用 AGPLv3——这是一种 copyleft 许可证,如果你把它作为服务提供给他人就会受影响。Agent SDK 和 MCP 服务器放在单独的仓库中,采用 MIT 许可证。
它能计量和计费哪些类型的用量?任何你能以事件形式发出的东西:按模型、输入、输出、缓存、推理或工具调用统计的 LLM token;GPU、CPU 和存储消耗;API 调用、交易、席位数和自定义事件——还支持带自动充值的预付费积分,以及带最低承诺量和超额计费的订阅。
Lago Direct 和 Lago Embedded 有什么区别?Direct 是标准模式:你为自己的产品的客户做计量和计费,就像 Mistral AI 那样。Embedded 则把同一套引擎做成白标方案,让平台和交易市场可以在自己的产品内以自己的品牌提供计费能力,就像 PayPal 那样。
AI 智能体能直接和 Lago 配合使用吗?可以,它对智能体非常友好:MCP 服务器为智能体提供针对发票、用量、客户和收款的读写工具,Python 和 JS/TS 的 Agent SDK 可以为 OpenAI、Anthropic、Mistral 和 Gemini 客户端埋点,包装层的 p99 开销低于 5 毫秒。
它在真实的大规模场景下能用于生产环境吗?这正是它的设计目标:以 transaction_id 去重的幂等接入、原子批次、可隔离的异步 worker、Prometheus 指标,以及 SOC 2 Type II 认证。Synthesia 和 Blacksmith 都在公开地用它支撑自己的计费。
Creator
getlago
Size
153.2 MB
Stars
10.7K
Age
4y
Commits · 90 Days