fix(provider): resolve OpenRouter route-modifier suffixes in model IDs - #48117
Open
xiaoguomeiyitian wants to merge 1 commit into
Open
xiaoguomeiyitian wants to merge 1 commit into
xiaoguomeiyitian wants to merge 1 commit into
Conversation
xiaoguomeiyitian
force-pushed
the
openrouter-route-modifiers
branch
4 times, most recently
from
September 12, 2026 00:30
dc50a95 to
ce657da
Compare
OpenRouter route modifiers (:floor, :nitro, :exacto, :online) are request-time routing suffixes, not catalog model keys, so references like openrouter/openai/gpt-5.6-luna:floor always failed model lookup with ModelNotFoundError even though OpenRouter accepts the identifier. When exact model-ID lookup fails, strip a known route-modifier suffix and resolve against the base catalog model, keeping the suffixed ID for provider requests so the routing modifier still applies. Fixes anomalyco#48016
xiaoguomeiyitian
force-pushed
the
openrouter-route-modifiers
branch
from
September 16, 2026 04:15
ce657da to
81ec2ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #48016
Type of change
What does this PR do?
OpenRouter exposes request-time route modifiers as
:suffixes on a model slug —:floor,:nitro,:exacto,:online(and others like:freethat do appear as catalog keys). These modifiers are not separate model SKUs, so they never appear as keys in the models.dev catalog. As a result, a reference likeopenrouter/openai/gpt-5.6-luna:floorfails lookup inProvider.getModelwithModelNotFoundError, even though OpenRouter routes that exact identifier fine when it is passed straight through.The fix is scoped to the lookup step. When the exact
provider.models[modelID]lookup misses and the provider isopenrouter, strip a known route-modifier suffix and resolve against the base catalog model. The returned model keeps the suffixed ID in bothmodel.idandmodel.api.id, so downstream request paths (getLanguage→sdk.languageModel(model.api.id)in the AI SDK path, andLLMNativeRuntimein the native path) still send the modifier to OpenRouter.Why it works: the base model entry carries everything the resolver needs (capabilities, cost, request config, npm/package), and the only thing that differs is the identifier OpenRouter should receive, which is exactly what the suffix expresses. Keeping the suffixed ID on
api.idmeans the modifier is preserved end-to-end without touching any other provider path.The fallback is deliberately narrow: only for
openrouter, only for the four documented route-modifier suffixes, and only when the base model is present in the catalog. Unknown suffixes and missing bases keep the existingModelNotFoundError+ suggestions behavior.How did you verify your code works?
packages/opencode/test/provider/provider.test.ts:getModel resolves OpenRouter route-modifier suffixes against the base model— assertsopenai/gpt-5.6-luna:floorresolves and that bothmodel.idandmodel.api.idcarry the suffixed value with the openrouter npm package.getModel throws ModelNotFoundError for unknown route-modifier base— assertsopenai/nonexistent-model:floorstill fails.bun run typecheckinpackages/opencodepasses.packages/opencodeprovider suite passes (bun test test/provider/— 715 passing; oneheader-timeouttest is a pre-existing timing flake that also fails on the unmodified baseline when run in parallel).Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
N/A — backend model-resolution change, no UI.
Checklist