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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import { NextRequest, NextResponse } from "next/server";
export const dynamic = "force-dynamic";
import { clearMemoryCache, getMemoryCacheStats } from "@/lib/semanticCache";
import { isAuthenticated, isCacheScopedKey } from "@/shared/utils/apiAuth";
import { CACHE_READ_SCOPE, CACHE_WRITE_SCOPE } from "@/shared/constants/managementScopes";
import { sanitizeErrorMessage } from "@omniroute/open-sse/utils/error.ts";
export async function GET(req: NextRequest) {
if (!(await isAuthenticated(req)) && !(await isCacheScopedKey(req, CACHE_READ_SCOPE))) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
try {
return NextResponse.json(getMemoryCacheStats());
} catch (error) {
return NextResponse.json({ error: sanitizeErrorMessage(error) }, { status: 500 });
}
}
export async function DELETE(req: NextRequest) {
if (!(await isAuthenticated(req)) && !(await isCacheScopedKey(req, CACHE_WRITE_SCOPE))) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
try {
clearMemoryCache();
return NextResponse.json({ success: true, message: "Cache cleared" });
} catch (error) {
return NextResponse.json({ error: sanitizeErrorMessage(error) }, { status: 500 });
}
}