Skip to content

fix(llm): allow unlisted OpenRouter model overrides - #1610

Merged
lizhengfeng101 merged 4 commits into
alibaba:mainfrom
Dante-dan:fix/1609-openrouter-model-override
Oct 5, 2026
Merged

lizhengfeng101 merged 4 commits into
alibaba:mainfrom
Dante-dan:fix/1609-openrouter-model-override

Conversation

@Dante-dan

Copy link
Copy Markdown
Contributor

Description

The built-in OpenRouter preset lists a handful of models for ocr config model. The resolver also treated that list, combined with configured suggestions, as an allowlist for --model, so valid OpenRouter IDs absent from the list failed before a request reached OpenRouter.

This change marks OpenRouter's model list as open for per-run overrides. The listed models remain picker suggestions; an unlisted ID passes through for OpenRouter to validate. Closed-list providers and the existing Bedrock exception keep their current behavior. The CLI reference documents the distinction.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally (race enabled; Go 1.25.5, macOS arm64)
  • Manual testing (describe below)

The new resolver test selects the built-in OpenRouter provider with a configured model suggestion and passes an unlisted ID via --model. Existing tests cover rejection by closed-list providers. go generate ./internal/llm produced no catalog changes; make check, make build, and git diff --check passed. No live OpenRouter request was made. The required ocr review --audience agent command was attempted with the locally built CLI but could not resolve an LLM endpoint because none is configured in this environment.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI/LLM disclosure: Codex using GPT-6 Sol assisted with investigation, implementation, tests, documentation, and this description. A human contributor review and CLA signature are not claimed here.

Related Issues

Closes #1609.

@CLAassistant

CLAassistant commented Sep 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 2 issue(s) in this PR.

  • ✅ Successfully posted inline: 2 comment(s)

Comment thread internal/llm/providers.go Outdated
Protocol: ProtocolOpenAIChatCompletions,
BaseURL: "https://openrouter.ai/api/v1",
EnvVar: "OPENROUTER_API_KEY",
OpenModelList: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation · high
Documentation sync required. Per project rules, any modification of a provider entry must be accompanied by updates to the built-in provider table in all four documentation files (en/configuration.md, zh/configuration.md, ja/configuration.md, ru/configuration.md). The docs currently list OpenRouter without mentioning that its model list is non-gating (open catalog). Please update all four docs to reflect this behavioral difference.

Comment thread internal/llm/providers.go Outdated
Protocol: ProtocolOpenAIChatCompletions,
BaseURL: "https://openrouter.ai/api/v1",
EnvVar: "OPENROUTER_API_KEY",
OpenModelList: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test · medium
Missing test coverage for new field. The existing TestLookupProvider_OpenRouterDetails test verifies Protocol, BaseURL, and EnvVar but does not assert OpenModelList == true. Since this new field changes resolver behavior (disabling model-list gating), add an assertion like if !p.OpenModelList { t.Error("expected OpenModelList to be true") } to prevent accidental regression.

@Qiyuanqiii Qiyuanqiii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@Dante-dan

Copy link
Copy Markdown
Contributor Author

done

@Qiyuanqiii Qiyuanqiii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed 3a63e3e.

The OpenRouter override change is appropriately scoped: its preset/configured model entries remain picker suggestions, while unlisted per-run IDs can reach the provider. Closed-list presets retain their validation, and the existing ambient-auth exception is preserved.

The earlier bot requests are addressed in this revision: the OpenRouter preset flag has a direct assertion, the resolver test covers an unlisted model alongside configured suggestions, and the four provider-table documentation pages have been updated.

I found no code-level blocker.

@wu21-web

wu21-web commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

@Qiyuanqiii @Dante-dan If valid models ID are not in the default registry, you either

  • Add them to the default registry

or

  • Per the documentation:
ocr config set provider                    anthropic
ocr config set model                       claude-opus-4-6
ocr config set providers.anthropic.api_key sk-ant-xxxxxxxxxx

Note that the existance check is enforced by default. There is no way to bypass it.
Here is how:

femboy@femboys-Mac-mini ~ % ocr config set provider openrouter
Set provider = openrouter
femboy@femboys-Mac-mini ~ % echo $?
0
femboy@femboys-Mac-mini ~ % ocr config set model deepseek/deepseek-v4.1-flash
Set model = deepseek/deepseek-v4.1-flash
femboy@femboys-Mac-mini ~ % # Then set a API key and review again

cc @moltar

@moltar

moltar commented Oct 4, 2026

Copy link
Copy Markdown

That's just too many steps to do something simple.

It worked, and still works, perfectly fine with a custom provider configured to use OpenRouter. And I can pass any model via --model flag.

Switching to an official provider once it was released was a downgrade in my experience. That's why I raised this feature request.

@wu21-web

This comment was marked as outdated.

Comment thread internal/llm/providers.go Outdated
Protocol: ProtocolOpenAIChatCompletions,
BaseURL: "https://openrouter.ai/api/v1",
EnvVar: "OPENROUTER_API_KEY",
OpenModelList: true,

@wu21-web wu21-web Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only effective to Open router?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, OpenRouter is just a example. The issue means "Get rid of the validation check and allow any input from --model flag. If you have a different understanding, let me know.

@moltar

moltar commented Oct 4, 2026

Copy link
Copy Markdown

I would not really recommend bypassing the validator but if that is the point of this PR I won't block it

Could you please explain why?

What's the benefit of this validator?

@wu21-web

wu21-web commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

I previously thought that this validator keeps out invalid models, it is also designed to keep out outdated models that does not have enough agentic abilities. Generally most models are included in that list. If you want to bypass that ruleset than you have to manual configure a model through ocr config. From my experience, removing outdated models is what we do in every provider registration PR.

As I said here, I will not block anyone. If you have confusion, feel free to ask. If you disagree, ignoring my opinion is totally fine.

By the way, take a look at this: #1610 (comment)

Do you mean you want to get rid of all constrained items, not only for Open router but also for other providers as well?

@moltar

moltar commented Oct 4, 2026

Copy link
Copy Markdown

I didn't mean that as I didn't get stuck on any other option.

Models get released all the time I think it's unrealistic to keep up with any kind of list. Perhaps, at best, there can be a deprecated model list that simply warns user of using an older model.

That's the main reason I just want to pass models available on OR thru --model. I have a skill that uses ocr to do reviews. Many engineers may have different versions of ocr on their machines and have configured different models. The skill instructs using specific models. If user doesn't have those in models array then --model fails to work. So we have to now tell all users to update their ocr config.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@Dante-dan The docs are currently inconsistent across the five locales (en, zh, ja, ko, ru). Could you either (1) remove the cli-reference.md change and sync configuration.md across all five locales (Korean is missing), or (2) sync both files across all five locales?

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@Dante-dan Thanks for putting this together. The per-run OpenRouter model override is valuable, and I'd like to help get this PR merged sooner. I'll take over the remaining work directly in this PR, including syncing the docs across all five locales, and keep the changes focused. Please let me know if you have any updates in progress so we can avoid conflicts.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 182898c into alibaba:main Oct 5, 2026
15 checks passed
SaahiilM added a commit to SaahiilM/open-code-review that referenced this pull request Oct 5, 2026
fix(llm): allow unlisted OpenRouter model overrides (alibaba#1610)
SaahiilM added a commit to SaahiilM/open-code-review that referenced this pull request Oct 5, 2026
fix(llm): allow unlisted OpenRouter model overrides (alibaba#1610)
SaahiilM added a commit to SaahiilM/open-code-review that referenced this pull request Oct 19, 2026
fix(llm): allow unlisted OpenRouter model overrides (alibaba#1610)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow any OpenRouter model ID in --model for the built-in openrouter provider

6 participants