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: /v1/models respects disabled providers — track total connections before filter

diegosouzapwf12b90f373b3
diff --git a/src/app/api/v1/models/route.ts b/src/app/api/v1/models/route.ts
index 4f75854d9a..9d939ff003 100644
--- a/src/app/api/v1/models/route.ts
+++ b/src/app/api/v1/models/route.ts
@@ -100,8 +100,10 @@ export async function GET() {
// Get active provider connections
let connections = [];
+ let totalConnectionCount = 0; // Track if DB has ANY connections (even disabled)
try {
connections = await getProviderConnections();
+ totalConnectionCount = connections.length;
// Filter to only active connections
connections = connections.filter((c) => c.isActive !== false);
} catch (e) {
@@ -149,7 +151,7 @@ export async function GET() {
// If we have active providers, only include those; otherwise include all
if (
- connections.length > 0 &&
+ totalConnectionCount > 0 &&
!activeAliases.has(alias) &&
!activeAliases.has(canonicalProviderId)
) {
@@ -186,7 +188,7 @@ export async function GET() {
// Helper: check if a provider is active (by provider id or alias)
const isProviderActive = (provider: string) => {
- if (connections.length === 0) return true; // No connections configured = show all
+ if (totalConnectionCount === 0) return true; // No connections configured = show all
const alias = providerIdToAlias[provider] || provider;
return activeAliases.has(alias) || activeAliases.has(provider);
};
@@ -262,7 +264,7 @@ export async function GET() {
const canonicalProviderId = FALLBACK_ALIAS_TO_PROVIDER[alias] || providerId;
// Only include if provider is active (or no connections configured)
if (
- connections.length > 0 &&
+ totalConnectionCount > 0 &&
!activeAliases.has(alias) &&
!activeAliases.has(canonicalProviderId)
)