mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 04:57:00 +01:00
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
13 lines
560 B
TypeScript
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" } },
|
|
);
|
|
}
|