Files
loki/scripts/site-template/lib/limits.ts
Catoandgithub-actions[bot] d7a882fbec chore(starter): sync scripts/site-template to bitbaum/fleet@5dc0be8081 (#1467)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-29 12:15:40 +01:00

13 lines
560 B
TypeScript

import { slidingWindow, toHeaders, type LimitResult } from "limitkit";
/** App-only budgets; account limits and proxy/recipient keys belong to accountkit. */
export const limits = {
ai: slidingWindow({ limit: 20, windowMs: 60 * 60_000 }),
modelProbe: slidingWindow({ limit: 20, windowMs: 10 * 60_000 }),
};
export function tooMany(result: LimitResult): Response {
return Response.json(
{ error: "rate_limited", retryAfterSeconds: result.retryAfterSeconds },
{ status: 429, headers: { ...toHeaders(result), "Cache-Control": "no-store" } },
);
}