Larz › Monetize an API in Python

Monetize your Python API

Keys, metering, validation, and docs — the complete stack for a paid JSON API, in one framework.

pip install larz
@app.api_key_required(plan="pro")
@app.validate({"text": {"type": str, "required": True}})
@app.metered("$0.01/call")
@app.post("/api/summarize")
def summarize(req):
    return {"summary": run(req.data["text"])}

QuickstartGitHubFree course

The pieces

See the step-by-step tutorial and the runnable examples/paid_api.py.

FAQ

How do I charge for a Python API?

Issue API keys with app.auth.issue_api_key(plan=...), gate the endpoint with @app.api_key_required, and meter it with @app.metered. Larz bills each key per call.

Does Larz generate API docs?

Yes — app.enable_docs() serves an OpenAPI spec at /openapi.json and a browsable page at /docs, generated from your routes and validation schemas.