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

feat(gemini): auto-trigger model sync when API key is saved

Chris Staley5c27e0f9ef1f
diff --git a/src/app/api/providers/route.ts b/src/app/api/providers/route.ts
index 0c5e06a156..5b8fb981f3 100644
--- a/src/app/api/providers/route.ts
+++ b/src/app/api/providers/route.ts
@@ -15,6 +15,7 @@ import { getConsistentMachineId } from "@/shared/utils/machineId";
import { syncToCloud } from "@/lib/cloudSync";
import { createProviderSchema } from "@/shared/validation/schemas";
import { isValidationFailure, validateBody } from "@/shared/validation/helpers";
+import { buildModelSyncInternalHeaders } from "@/shared/services/modelSyncScheduler";
// GET /api/providers - List all connections
export async function GET() {
@@ -139,6 +140,23 @@ export async function POST(request: Request) {
testStatus: testStatus || "unknown",
});
+ // Auto-trigger model sync for Gemini when API key is saved
+ if (provider === "gemini" && newConnection?.id) {
+ try {
+ const origin = new URL(request.url).origin;
+ fetch(`${origin}/api/providers/${newConnection.id}/sync-models`, {
+ method: "POST",
+ headers: {
+ ...buildModelSyncInternalHeaders(),
+ cookie: request.headers.get("cookie") || "",
+ },
+ }).catch((e) => console.error("Auto-sync failed for gemini:", e));
+ } catch (e) {
+ // Non-blocking — don't fail the connection save
+ console.error("Failed to trigger auto-sync for gemini:", e);
+ }
+ }
+
// Hide sensitive fields
const result: Record<string, any> = { ...newConnection };
delete result.apiKey;