The token tracker is a shared infrastructure layer that captures LLM token usage from provider responses and feeds two consumers: the rate limiter (tokens/time) and the spend limiter (cost/time). It uses a write-through cache pattern with Redis for fast aggregation and PostgreSQL for durable storage.
graph TB
subgraph "Middleware Chain"
OIDC["OIDC Auth"]