Metering, Plans & Subscriptions
Charge per API call, sell named plans with trials, and give customers a self-serve billing portal.
Pay per call
@app.metered bills a prepaid credit balance on each request and returns a clean
402 Payment Required when the caller runs out.
@app.metered("$0.02/call")
@app.post("/api/run")
def run(req):
return {"ok": True} # caller debited 2c per call
Named plans with trials
app.money.plan("pro", "$9/mo", features=["A", "B"], trial_days=7)
@app.plan("pro")
@app.get("/dashboard")
def dash(req): ...
The subscription lifecycle
Subscriptions auto-expire and re-prompt at renewal. Larz serves a customer portal at
/larz/account where users see their plan, cancel it, view invoices, and top up
credits โ all without you writing a page.
app.money.cancel(subject, "plan:pro") # at period end
@app.money.on_grant
def welcome(subject, sku): ... # hook grants (e.g. send email)
Takeaways
@app.metered= usage billing;@app.plan= tiers; both are one line.- Invoices, receipts, cancellation and the portal are built in.
- Swap the payment provider (Stripe, Paddle, PayPal, โฆ) without touching your routes.