All use casesUse Case
The billing and multi-tenant layer that turns an LLM feature into a SaaS product.
The difference between an LLM demo and an AI SaaS product is usage-based billing, per-customer rate limits, and API key management. FastAPI AI Kit ships all three pre-wired to Stripe, so the SaaS mechanics are done before you write your first product feature.
FastAPIStripePostgreSQLRedisOpenAI / Anthropic
The usual pain points
- ✕Metering usage accurately enough to bill customers fairly
- ✕Issuing and managing API keys per customer or per plan tier
- ✕Enforcing different rate limits across free, basic, and pro tiers
- ✕Handling Stripe webhook events for upgrades, downgrades, and cancellations
How the kit solves them
- Stripe usage metering wired to per-request token/event counts out of the box
- API key issuance, rotation, and revocation built into the auth layer
- Per-tier rate limiting configurable per minute and per day
- Webhook handler for subscription lifecycle events included
Example implementation
@router.post("/v1/process")
@require_api_key(tier=["free", "basic", "pro"])
@rate_limit(per_minute=60, per_day=10_000)
async def process(body: ProcessRequest, key: APIKey = Depends(get_api_key)):
result = await llm.chat(messages=build_prompt(body), track_tokens=True)
await meter.record(key.id, units=result.tokens) # feeds Stripe usage record
return {"output": result.content}Ready to build your ai saas boilerplate?
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.
No subscriptions · One-time payment · Lifetime updates
