Skip to content

Commit 4a5e90e

Browse files
committed
fix: filter all model types in /v1/models by active providers
Previously only chat models were filtered by active provider connections. Embedding, image, rerank, audio, and moderation models were always shown regardless of whether the provider had any configured connections. This caused providers like Together AI to appear in /v1/models even when no API key was configured. Closes #81
1 parent 91db553 commit 4a5e90e

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/app/api/v1/models/route.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,16 @@ export async function GET() {
184184
}
185185
}
186186

187-
// Add embedding models
187+
// Helper: check if a provider is active (by provider id or alias)
188+
const isProviderActive = (provider: string) => {
189+
if (connections.length === 0) return true; // No connections configured = show all
190+
const alias = providerIdToAlias[provider] || provider;
191+
return activeAliases.has(alias) || activeAliases.has(provider);
192+
};
193+
194+
// Add embedding models (filtered by active providers)
188195
for (const embModel of getAllEmbeddingModels()) {
196+
if (!isProviderActive(embModel.provider)) continue;
189197
models.push({
190198
id: embModel.id,
191199
object: "model",
@@ -196,8 +204,9 @@ export async function GET() {
196204
});
197205
}
198206

199-
// Add image models
207+
// Add image models (filtered by active providers)
200208
for (const imgModel of getAllImageModels()) {
209+
if (!isProviderActive(imgModel.provider)) continue;
201210
models.push({
202211
id: imgModel.id,
203212
object: "model",
@@ -208,8 +217,9 @@ export async function GET() {
208217
});
209218
}
210219

211-
// Add rerank models
220+
// Add rerank models (filtered by active providers)
212221
for (const rerankModel of getAllRerankModels()) {
222+
if (!isProviderActive(rerankModel.provider)) continue;
213223
models.push({
214224
id: rerankModel.id,
215225
object: "model",
@@ -219,8 +229,9 @@ export async function GET() {
219229
});
220230
}
221231

222-
// Add audio models (transcription + speech)
232+
// Add audio models (filtered by active providers)
223233
for (const audioModel of getAllAudioModels()) {
234+
if (!isProviderActive(audioModel.provider)) continue;
224235
models.push({
225236
id: audioModel.id,
226237
object: "model",
@@ -231,8 +242,9 @@ export async function GET() {
231242
});
232243
}
233244

234-
// Add moderation models
245+
// Add moderation models (filtered by active providers)
235246
for (const modModel of getAllModerationModels()) {
247+
if (!isProviderActive(modModel.provider)) continue;
236248
models.push({
237249
id: modModel.id,
238250
object: "model",

0 commit comments

Comments
 (0)