Most OpenRouter models missing in Local Mode
Description
When using OpenRouter in Local Mode, many models retrieved from the OpenRouter API do not appear in the system.
This happens due to two related issues in the pricing sync and caching logic:
- OpenRouter models are not stored with provider = OpenRouter.
- The pricing cache assumes model_name is unique, causing collisions when multiple providers share the same model.
Together, these issues prevent many OpenRouter models from appearing in the available models list.
Problem 1: Incorrect provider assignment
The pricing sync retrieves models from the OpenRouter API. Example model ID:
The provider is derived from the vendor prefix:
canonical: gpt-4.1
provider: OpenAI
The database entry becomes:
model_name | provider
gpt-4.1 | OpenAI
However, users access this model via OpenRouter, not directly through the vendor.
When models are filtered by provider:
activeProviders = ['ollama', 'openrouter']
The check:
activeProviders.has(m.provider.toLowerCase())
evaluates to:
openrouter.has(openai) → false
So the model is excluded even though it is available through OpenRouter.
Problem 2: Cache key collision
To properly support OpenRouter, the same model may exist for multiple providers:
model_name | provider
gpt-4.1 | OpenAI
gpt-4.1 | OpenRouter
However, pricingCache.reload() uses only model_name as the cache key:
this.cache.set(row.model_name, row);
When duplicates exist:
- gpt-4.1 | OpenAI is cached
- gpt-4.1 | OpenRouter is cached
- The second entry overwrites the first
Which entry survives depends on query order.
Impact
- Many OpenRouter models are missing
- available-models returns incomplete results
- Provider filtering behaves inconsistently
- Local Mode users cannot access most OpenRouter models
Affected components
- syncPricing
- syncAllModels
- pricingCache.reload
- available-models endpoint
- provider filtering logic
Most OpenRouter models missing in Local Mode
Description
When using OpenRouter in Local Mode, many models retrieved from the OpenRouter API do not appear in the system.
This happens due to two related issues in the pricing sync and caching logic:
Together, these issues prevent many OpenRouter models from appearing in the available models list.
Problem 1: Incorrect provider assignment
The pricing sync retrieves models from the OpenRouter API. Example model ID:
The provider is derived from the vendor prefix:
The database entry becomes:
However, users access this model via OpenRouter, not directly through the vendor.
When models are filtered by provider:
The check:
evaluates to:
So the model is excluded even though it is available through OpenRouter.
Problem 2: Cache key collision
To properly support OpenRouter, the same model may exist for multiple providers:
However, pricingCache.reload() uses only model_name as the cache key:
When duplicates exist:
Which entry survives depends on query order.
Impact
Affected components