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
fix(model-sync): skip replace when auto-sync returns empty model list
tombii557509ef8431
diff --git a/src/app/api/provider-models/route.ts b/src/app/api/provider-models/route.tsindex c230d8fcca..5fbfcd3b92 100644--- a/src/app/api/provider-models/route.ts+++ b/src/app/api/provider-models/route.ts@@ -258,7 +258,7 @@ export async function DELETE(request) {// DELETE /api/provider-models?provider=<id>&all=true — clear all modelsconst all = searchParams.get("all");if (all === "true") {- await replaceCustomModels(provider, []);+ await replaceCustomModels(provider, [], { allowEmpty: true });return Response.json({ cleared: true });}diff --git a/src/lib/db/models.ts b/src/lib/db/models.tsindex 671fbc1465..9c1538e102 100644--- a/src/lib/db/models.ts+++ b/src/lib/db/models.ts@@ -383,7 +383,8 @@ export async function replaceCustomModels(source?: string;apiFormat?: string;supportedEndpoints?: string[];- }>+ }>,+ { allowEmpty = false }: { allowEmpty?: boolean } = {}) {const db = getDbInstance();const existing = await getCustomModels(providerId);@@ -420,6 +421,12 @@ export async function replaceCustomModels(});if (merged.length === 0) {+ // Guard: skip destructive clear when the caller hasn't explicitly opted in.+ // This prevents auto-sync from wiping manually-imported models when the+ // upstream /models endpoint fails, times out, or returns an empty list.+ if (!allowEmpty) {+ return Array.isArray(existing) ? existing : [];+ }db.prepare("DELETE FROM key_value WHERE namespace = 'customModels' AND key = ?").run(providerId);