Skip to content

Missing OpenRouter models in Local Mode #1088

@JoseArroyave

Description

@JoseArroyave

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:

  1. OpenRouter models are not stored with provider = OpenRouter.
  2. 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:

openai/gpt-4.1

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:

  1. gpt-4.1 | OpenAI is cached
  2. gpt-4.1 | OpenRouter is cached
  3. 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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions