Lago
Use Lago for MainSDK usage metering - open-source usage billing, self-hosted or cloud, main.yaml, testing and swapping.
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.
meterBuilding for 0.3Driver lago Lago
later, as an export target behind pay
meter:
driver: lagoBefore you start
- Run Lago yourself or create a hosted Lago account.
- Define the billable metrics and plans you charge on.
- Create an API key for your app.
Configure
meter:
driver: lagoHow 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
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;
meterhas 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
meter:
driver: lago # was stripe-metersFAQ
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?