โšก Software ยท LARZ-101 · Session 3 of 8

Metering, Plans & Subscriptions

Charge per API call, sell named plans with trials, and give customers a self-serve billing portal.

⏱ 11 min read📅 Updated 2026-07-25📊 Code examples throughout

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.

More in this course

Course home → · Browse all courses →