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: improve error handling in custom model API call

Nyaru Torubf49fdf0bf09
diff --git a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx b/src/app/(dashboard)/dashboard/providers/[id]/page.tsx
index 5a49ebe6a2..3e56f81d1f 100644
--- a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx
+++ b/src/app/(dashboard)/dashboard/providers/[id]/page.tsx
@@ -1511,9 +1511,15 @@ function CompatibleModelsSection({
});
if (!customModelRes.ok) {
- const errorData = await customModelRes.json().catch(() => ({}));
+ let errorData = {};
+ try {
+ errorData = await customModelRes.json();
+ } catch (jsonError) {
+ console.error("Failed to parse error response from custom model API:", jsonError);
+ }
throw new Error(errorData.error?.message || "Failed to save custom model");
}
+ }
// Only create alias after customModel is saved successfully
await onSetAlias(modelId, resolvedAlias, providerStorageAlias);