---
title: Sliding-Window Rate Limiting for AI APIs | APIkit
description: Enforce accurate sliding-window rate limits on every AI endpoint without deploying Redis clusters or gateway proxies.
canonical: "https://apikit.ai/j/apply-sliding-window-rate-limits"
modified: 2026-11-14
author: apikit.ai editorial team
source: "https://apikit.ai"
category: Response Caching & Rate Limiting
category_url: "https://apikit.ai/j#group-caching-rate-limiting"
---

# Protect AI endpoints with sliding-window rate limits

> Prevent traffic bursts and abusive scrapers from draining token budgets with smooth per-IP, per-key, and per-user sliding limits.

## Prepared starting prompt

We expose a public AI summarizer widget and need sliding-window rate limits of 15 requests per minute per IP without spinning up Redis.

### Quick scenarios
- **No Redis setup needed:** Configure per-minute and per-hour sliding limits natively in the endpoint settings.
- **Per-IP & per-key rules:** Limit anonymous traffic by IP while keying authenticated SaaS requests on tenant_id.
- **Token-aware rate caps:** Cap both request counts and total tokens consumed inside each rolling time window.

- [Join the APIkit waitlist](https://apikit.ai/#waitlist-f73a0d)

## Checklist for smooth sliding-window limits

1. **Prefer sliding over fixed windows** — Avoid boundary-minute double bursts where callers fire 2x capacity at :59 and :01 seconds.
2. **Combine burst and sustained caps** — Allow short 5-request interactive bursts while capping total sustained calls per hour.
3. **Key behind trusted proxy headers** — Extract real client IPs cleanly when traffic arrives via Cloudflare or application proxies.
4. **Separate limit buckets by route** — Give cheap classification routes generous caps while guarding expensive generation tightly.

## Frequently Asked Questions

### Why are sliding windows better than fixed 60-second buckets?

Fixed buckets let bursts fire twice the limit across a minute boundary. Sliding windows enforce smooth continuous limits.

### Can I limit by tokens consumed instead of just request count?

Yes. Token-bucket and TPM rate limits prevent callers from sneaking huge prompts under a small request-count limit.

### Do I need an external Redis instance for distributed limits?

No. APIkit enforces distributed rate limits globally across edge nodes automatically.

## Related tasks in this category

- [Cache identical AI responses at the edge for instant hits](https://apikit.ai/j/cache-identical-ai-api-responses.md)
- [Cut LLM costs with semantic similarity response caching](https://apikit.ai/j/enable-semantic-similarity-caching.md)
- [Throttle AI endpoints automatically by customer plan tier](https://apikit.ai/j/throttle-expensive-endpoints-by-plan.md)
- [Manage cache TTLs and purge stale AI outputs instantly](https://apikit.ai/j/configure-ttl-cache-invalidation.md)
- [Stop infinite client retry loops from draining AI spend](https://apikit.ai/j/prevent-prompt-loop-billing-runaway.md)
- [Coalesce simultaneous identical AI calls into one run](https://apikit.ai/j/coalesce-concurrent-duplicate-requests.md)

---

*Published by **Wondel.ai sp. z o.o.** · [apikit.ai](https://apikit.ai) · [About](https://apikit.ai/about) · [Editorial Guidelines](https://apikit.ai/editorial) · [Contact](https://apikit.ai/contact) · [Wondel.ai Products](https://wondel.ai/products)*