diff --git a/open-sse/config/embeddingRegistry.ts b/open-sse/config/embeddingRegistry.ts index 85758e4535..f0badede8d 100644 --- a/open-sse/config/embeddingRegistry.ts +++ b/open-sse/config/embeddingRegistry.ts @@ -239,7 +239,7 @@ export const EMBEDDING_PROVIDERS: Record = { { id: "google/gemini-embedding-001", name: "Gemini Embedding 001 (OpenRouter)", - dimensions: 768, + dimensions: 3072, }, { id: "google/gemini-embedding-2", diff --git a/src/app/api/v1/models/catalog.ts b/src/app/api/v1/models/catalog.ts index 214232e7bf..16f98af037 100644 --- a/src/app/api/v1/models/catalog.ts +++ b/src/app/api/v1/models/catalog.ts @@ -1357,13 +1357,13 @@ async function buildUnifiedModelsResponseCore( return activeAliases.has(alias) || activeAliases.has(provider); }; - const hasEquivalentSpecialtyModel = ( + const findEquivalentSpecialtyModel = ( providerId: string, rawModelId: string, type: string, scopedModelId: string ) => - models.some((model: any) => { + models.find((model: any) => { if (model?.id === scopedModelId) return true; if (model?.owned_by !== providerId || model?.type !== type) return false; const existingRoot = @@ -1375,6 +1375,13 @@ async function buildUnifiedModelsResponseCore( return existingRoot === rawModelId; }); + const hasEquivalentSpecialtyModel = ( + providerId: string, + rawModelId: string, + type: string, + scopedModelId: string + ) => findEquivalentSpecialtyModel(providerId, rawModelId, type, scopedModelId) !== undefined; + // Helper: strip the provider prefix from a specialty model ID to get the // provider-relative path (e.g. "openrouter/google/chirp-3" -> "google/chirp-3"). // This is the correct key used by the hidden-model lookup — using .split("/").pop() @@ -1389,7 +1396,22 @@ async function buildUnifiedModelsResponseCore( const rawModelId = getSpecialtyModelRelativeId(embModel.id, embModel.provider); if (!providerSupportsModel(embModel.provider, rawModelId)) continue; if (isModelHiddenBulk(embModel.provider, rawModelId)) continue; - if (hasEquivalentSpecialtyModel(embModel.provider, rawModelId, "embedding", embModel.id)) { + const existingEmbedding = findEquivalentSpecialtyModel( + embModel.provider, + rawModelId, + "embedding", + embModel.id + ); + if (existingEmbedding) { + // Discovery publishes no vector width, so the registry is the authority. + if (embModel.dimensions !== undefined) { + existingEmbedding.dimensions = embModel.dimensions; + } + // A provider that does not report its endpoints leaves the model unclassified. Being in + // the embedding registry is that statement, so make it rather than leave it untyped. + if (!existingEmbedding.type) { + existingEmbedding.type = "embedding"; + } continue; } models.push({