Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(api): validate model cooldown delete payload

diegosouzapw4f20fbc36c6f
diff --git a/src/app/api/resilience/model-cooldowns/route.ts b/src/app/api/resilience/model-cooldowns/route.ts
index f225614b38..52fa92da76 100644
--- a/src/app/api/resilience/model-cooldowns/route.ts
+++ b/src/app/api/resilience/model-cooldowns/route.ts
@@ -1,9 +1,19 @@
import { NextResponse } from "next/server";
+import { z } from "zod";
import {
clearModelUnavailability,
getAvailabilityReport,
resetAllAvailability,
} from "@/domain/modelAvailability";
+import { validateBody } from "@/shared/validation/helpers";
+
+const deleteCooldownSchema = z
+ .object({
+ provider: z.string().optional(),
+ model: z.string().optional(),
+ all: z.boolean().optional(),
+ })
+ .passthrough();
function getErrorMessage(error: unknown, fallback: string): string {
return error instanceof Error && error.message ? error.message : fallback;
@@ -24,11 +34,12 @@ export async function GET() {
export async function DELETE(request: Request) {
try {
- const body = (await request.json().catch(() => ({}))) as {
- provider?: string;
- model?: string;
- all?: boolean;
- };
+ const rawBody = await request.json().catch(() => ({}));
+ const validation = validateBody(deleteCooldownSchema, rawBody);
+ if (!validation.success) {
+ return NextResponse.json({ error: validation.error }, { status: 400 });
+ }
+ const body = validation.data;
if (body.all) {
resetAllAvailability();