Ai Rate Limiter
class AiRateLimiter(val name: String, maxRequests: Int = DEFAULT_MAX_REQUESTS, windowMs: Long = DEFAULT_WINDOW_MS, clock: () -> Long = System::currentTimeMillis)(source)
Thread-safe sliding-window rate limiter for AI API calls.
Allows up to maxRequests calls within each windowMs period. Once the limit is reached, subsequent calls are rejected until the window resets.
Parameters
name
Human-readable label used in log messages
max Requests
Maximum number of requests allowed per window
window Ms
Window duration in milliseconds