Rate Limiting & Abuse Controls
API rate limits
Section titled “API rate limits”- Per-route rate limits are enforced server-side. The limit key is the authenticated user’s organization when a bearer token is present, and the IP address otherwise.
- Rate-limited requests return HTTP 429 with a JSON body and a
Retry-Afterheader. - LLM-calling routes carry their own tighter per-organization limit so one tenant cannot drain the shared AI budget.
AI spend controls
Section titled “AI spend controls”- AI runs in mock mode by default (
AI_LIVE_CALLS_ENABLED=False). Mock output is deterministic, labeled, and costs nothing. - Live calls require a human gate (
PAID_EXTERNAL_CALLS_ENABLED) plus a kill switch (AI_ENABLED). - A hard monthly spend limit (default $60) is enforced in a shared ledger (Redis with a database fallback). Reaching it stops live calls until the window rolls over, and a web-process restart does not re-arm the cap.
- Per-user token and prompt quotas cap individual usage inside the monthly limit.
- Sync jobs are capped per source and per parse call, so an ingestion run cannot trigger unbounded model calls.