Skip to main content
All use casesUse Case

The complete backend for API-first SaaS products.

JWT auth, API key management, Stripe usage metering, rate limiting, and background jobs — the entire infrastructure layer for a SaaS API, pre-built and production-ready.

FastAPISQLAlchemyPostgreSQLStripeRedisCelery

The usual pain points

  • Building JWT auth and API key systems from scratch
  • Implementing usage-based billing that tracks actual consumption
  • Per-customer rate limiting across API keys
  • Background jobs for async processing without managing workers

How the kit solves them

  • Complete JWT + API key system on day one — issuance, rotation, revocation
  • Stripe usage metering hooks wired to per-request token/event counting
  • Per-key rate limiting with per-minute and per-day configurable limits
  • Celery + Redis or arq for background job processing, pre-configured

Example implementation

main.py
# Usage-metered endpoint — everything pre-wired
@router.post("/v1/process")
@require_api_key(tier=["basic", "pro"])
@rate_limit(per_minute=60, per_day=10_000)
async def process_request(
    body: ProcessRequest,
    key: APIKey = Depends(get_api_key),
):
    result = await processor.run(body.input)
    # Automatically meters usage to Stripe
    await meter.record(key.id, units=result.units)
    return ProcessResponse(output=result.data)

Ready to build your saas api backend?

FastAPI AI Kit ships with everything shown above, pre-configured and production-ready. Clone the repo and start building in minutes.

Ready to ship your AI backend this weekend?

Join developers who skipped weeks of boilerplate and went straight to building.

Read the docs
No subscriptions · One-time payment · Lifetime updates