BYOK & Per-Plan Limits
Let customers bring their own key, and gate AI by subscription tier.
Bring your own key
app.ai.set_byok(req.subject, "sk-customers-own-key") # encrypted at rest
# when a customer has a BYOK key, metering is skipped โ they pay their providerBYOK keys are encrypted with larz.crypto (authenticated encryption, no dependency). It's a popular model: power users bring their own key; everyone else buys credit from you.
Rate limits & unlimited tiers
@app.ai_metered("larz-writer", per_minute=30) # per-caller rate limit
# subscribers on a plan with {"ai_unlimited": True} skip the credit checkTakeaways
- BYOK keys never sit in plaintext;
has_byokgates metering. - Rate limits and unlimited plans are per-caller and per-tier.