fix: filter all model types in /v1/models by active providers (#88)

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

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-02-20 01:43:33 -03:00
committed by GitHub
parent 78b634b204
commit bc719875f6

View File

@@ -184,8 +184,16 @@ export async function GET() {
}
}
// Add embedding models
// 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
const alias = providerIdToAlias[provider] || provider;
return activeAliases.has(alias) || activeAliases.has(provider);
};
// Add embedding models (filtered by active providers)
for (const embModel of getAllEmbeddingModels()) {
if (!isProviderActive(embModel.provider)) continue;
models.push({
id: embModel.id,
object: "model",
@@ -196,8 +204,9 @@ export async function GET() {
});
}
// Add image models
// Add image models (filtered by active providers)
for (const imgModel of getAllImageModels()) {
if (!isProviderActive(imgModel.provider)) continue;
models.push({
id: imgModel.id,
object: "model",
@@ -208,8 +217,9 @@ export async function GET() {
});
}
// Add rerank models
// Add rerank models (filtered by active providers)
for (const rerankModel of getAllRerankModels()) {
if (!isProviderActive(rerankModel.provider)) continue;
models.push({
id: rerankModel.id,
object: "model",
@@ -219,8 +229,9 @@ export async function GET() {
});
}
// Add audio models (transcription + speech)
// Add audio models (filtered by active providers)
for (const audioModel of getAllAudioModels()) {
if (!isProviderActive(audioModel.provider)) continue;
models.push({
id: audioModel.id,
object: "model",
@@ -231,8 +242,9 @@ export async function GET() {
});
}
// Add moderation models
// Add moderation models (filtered by active providers)
for (const modModel of getAllModerationModels()) {
if (!isProviderActive(modModel.provider)) continue;
models.push({
id: modModel.id,
object: "model",