Skip to main content
All integrationsCache & Queue

Redis Integration

Rate limiting, session cache, and job queues — all via Redis.

Redis powers three distinct systems in FastAPI AI Kit: per-key rate limiting, session/response caching, and the Celery task queue for background jobs. All configured with sensible defaults.

Setup in 4 steps

  1. 1Set REDIS_URL in your .env
  2. 2Rate limiting is active automatically on decorated endpoints
  3. 3Celery worker starts via docker-compose or railway up
  4. 4Cache TTLs configurable in config.py

What's included

  • Per-API-key rate limiting with sliding window counters
  • Response caching for deterministic LLM endpoints
  • Celery broker + result backend for background jobs
  • Session store for multi-turn conversation history
  • Pub/sub for real-time job status updates

Code example

example.py
# Rate limiting stored in Redis — automatic
@rate_limit(per_minute=60, per_day=5000)
async def my_endpoint(...):
    ...

# Manual cache usage
from app.cache import cache

@cache(ttl=300)  # 5-minute cache on deterministic results
async def get_embedding(text: str) -> list[float]:
    return await openai.embeddings.create(input=text)

Full documentation: /docs/configuration

Redis integration pre-wired and ready.

FastAPI AI Kit ships with Redis configured out of the box. No manual setup required.

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