Skip to content

Filter OpenRouter models by user provider preferences, privacy settings, and guardrails #35506

Description

@ChihweiLHBird

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

When a user connects an OpenRouter API key to OpenCode, the model list currently comes from the static models.dev snapshot (provider.tsmodels.dev). It is not filtered by the user's OpenRouter account settings (provider preferences, privacy settings, guardrails, etc.). This causes OpenCode to display models that users explicitly disabled in their OpenRouter accounts.

OpenRouter provides a dedicated endpoint for this:

Using this endpoint when the user is authenticated with OpenRouter would ensure the model list reflects the user's actual available models.

If this idea is accepted, I may open a PR with the proposed changes mentioned below.

Current behavior

OpenCode shows all OpenRouter models from models.dev regardless of user preferences.

Proposed behavior

When a user has authenticated OpenRouter in OpenCode:

  1. Call GET https://openrouter.ai/api/v1/models/user with the stored OpenRouter API key.
  2. Use the returned model IDs to filter/disable models in the OpenCode OpenRouter provider catalog.
  3. Keep the rich metadata (capabilities, limits, pricing) from models.dev.
  4. Cache the filtered list per API key with a reasonable TTL (e.g. 5–15 minutes) to avoid excessive API calls.
  5. Gracefully fall back to the full models.dev OpenRouter list if the request fails.

Why this matters

  • Users see models they are actually allowed to use.
  • It respects user's privacy/guardrail settings in OepnRouter account.
  • It avoids the current mismatch where OpenCode lists models that OpenRouter rejects at request time.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions