๐Ÿค– Software ยท LARZ-501 · Session 5 of 8

BYOK & Per-Plan Limits

Let customers bring their own key, and gate AI by subscription tier.

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

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 provider

BYOK 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 check

Takeaways

  • BYOK keys never sit in plaintext; has_byok gates metering.
  • Rate limits and unlimited plans are per-caller and per-tier.

More in this course

Course home → · Browse all courses →