Rate Limits, Quotas, and Abuse Prevention

AI endpoints can be abused to consume expensive tokens, flood providers, or extract data at scale. Apply per-user and per-tenant rate limits, maximum input/output sizes, request timeouts, concurrency limits, and budget alerts. Use idempotency for retried jobs and queue bulk processing instead of allowing unbounded fan-out.

Rate limits should account for model cost and workload, not just request count. A 100-token classification request and a large multimodal request have different resource profiles. Return retry guidance for throttling and avoid exposing provider credentials or internal quota details unnecessarily.

Quota policy sketch
const limits = {
  requestsPerMinute: 20,
  maxInputCharacters: 20_000,
  maxOutputTokens: 1_000,
  maxConcurrentJobs: 3
};

// Enforce server-side per user/tenant, before provider invocation.
💡 These are illustrative values, not universal defaults. Derive limits from provider quotas, product requirements, user tiers, abuse patterns, and measured cost per request.
Key Takeaways
  • Limit both frequency and request size.
  • Track cost by user, tenant, feature, and model.
  • Queue expensive batch work and set budget alerts.
Knowledge Check

Why is request-count-only rate limiting insufficient for AI workloads?