Allow any OpenRouter model ID in --model for the built-in openrouter provider
Problem Statement
OpenRouter became a built-in provider in #1522. Its preset has a list of five models, and
ocr uses that list as an allowlist for --model. OpenRouter serves hundreds of models, so
most valid model IDs fail:
$ ocr review --provider openrouter --model deepseek/deepseek-v4.1-flash
model "deepseek/deepseek-v4.1-flash" is not available for provider "openrouter"; available models: anthropic/claude-fable-5.1, openai/gpt-5.6-sol, anthropic/claude-opus-5, openai/gpt-6-astra, moonshotai/kimi-k3The check is in tryProviderConfig in internal/llm/resolver.go. It compares --model
against the preset Models plus providers.openrouter.models, with an exact match.
The description of #1522 says users can enter other models by their exact ID. That works in
the ocr config model picker, but not with --model.
We run ocr in a review pipeline with a different OpenRouter model for each run, and we pick
the model on the command line. Before #1522 we used a custom provider for this. The built-in
provider is the better setup, but today it cannot run our models.
Proposed Solution
For openrouter, treat the preset model list as suggestions for the picker, not as an
allowlist for --model. Pass any model ID to OpenRouter and let OpenRouter reject an unknown
one.
The resolver already does this for ambient-auth providers such as Bedrock. The comment there
says the list "stays a picker for ocr config model; it does not gate an override". One way
to extend it is a field on Provider, for example OpenModelList bool, set on openrouter
and read in the same place as gateOverrideOnModelList. Other aggregator presets, such as
litellm or novita, could use the same field.
Alternatives Considered
- Add each model ID to
providers.openrouter.models. This works, but every new model needs a config change on every machine, and the list duplicates the model name we already pass. - Keep a custom provider pointed at
https://openrouter.ai/api/v1. This works, but it means we do not use the built-in provider at all. - Fetch the model list from
https://openrouter.ai/api/v1/models(the idea left open in #1540). This helps the picker, but a gate on a fetched list still fails when the fetch fails or the catalog changes.
Affected Area
CLI / Commands, Configuration
Additional Context
- #1522 added the preset. #1540 is the closed request for it.
- #705 added the Bedrock exception to the same gate.
- Version: v1.12.11 (the gate is the same in v1.12.10).
Source: alibaba/open-code-review