This commit is contained in:
Frank 2026-05-17 01:59:17 -04:00
commit 0b8050d453
4 changed files with 12 additions and 5 deletions

View file

@ -10,8 +10,11 @@ export function createRateLimiter(modelId: string, rateLimit: number | undefined
const dict = i18n(localeFromRequest(request))
const limits = Subscription.getFreeLimits()
const dailyLimit = rateLimit ?? limits.dailyRequests
const isDefaultModel = !rateLimit
const headersExist = Object.entries(limits.checkHeaders).every(
([name, value]) => request.headers.get(name)?.includes(value) ?? false,
)
const dailyLimit = !headersExist ? limits.dailyRequestsFallback : (rateLimit ?? limits.dailyRequests)
const isDefaultModel = headersExist && !rateLimit
const ip = !rawIp.length ? "unknown" : rawIp
const now = Date.now()