MainSDK
Search⌘K
Integrations

Lago

Use Lago for MainSDK usage metering - open-source usage billing, self-hosted or cloud, main.yaml, testing and swapping.

1 interface1 driverWritten guide
Updated 2026-10-28

Lago is an open-source usage billing tool you can host yourself or use as a hosted service. The lago driver behind meter sends each meter.record() to Lago, where you price and invoice it. Pick Lago when you want usage billing you can self-host, or when you don't bill through Stripe.

Interfaces it serves

Pick Lago in main.yaml for any of these. Your calls stay the same, and you can swap later.

Before you start

  1. Run Lago yourself or create a hosted Lago account.
  2. Define the billable metrics and plans you charge on.
  3. Create an API key for your app.

Configure

main.yaml
meter:
  driver: lago

How the driver takes its API key (as a secret: reference) and the Lago address, and how metrics map to Lago billable metrics, are not decided yet.

Use it

lib/usage.ts
import { meter } from "mainsdk";

await meter.record({ customer: org.id, metric: "api_calls", value: 1 });

Local development and testing

meter ships in phase 2, and its in-memory fake for createTestApp() from @mainsdk/testing arrives with its spec. Until then, a self-hosted Lago on your machine works for trying the flow.

What MainSDK adds on top

meter has no guarantees in the catalog yet; they arrive with its spec. Keys go in as secret: references. See Usage metering.

Limits and notes

  • Planned for phase 2; meter has no spec.
  • If you self-host Lago, usage data stays where you run it. Pick a host in your MainSDK data region (US, EU or India).
  • Not decided yet: whether a retried meter.record() counts once.

Swap to or from it

main.yaml
meter:
  driver: lago   # was stripe-meters

FAQ

Does Lago charge the card? Lago prices and invoices usage; collecting the payment is done by a payment provider you connect to it.

Can I use Lago with Stripe for payments? meter and pay are separate interfaces, so you can record usage in Lago and take payments through pay.

Next

Open questions

Was this page helpful?

↑↓ moveEnter openEsc close

Not decided yet