Repository navigation
fix(router): preserve vendor namespaces and catalog paths in wildcard discovery - #45531
Closed
apex-mochen wants to merge 1 commit into
Closed
apex-mochen wants to merge 1 commit into
apex-mochen wants to merge 1 commit into
Conversation
… discovery OpenRouter wildcard discovery requested /v1/models instead of /api/v1/models because the inherited OpenAI-compatible get_models stripped api_base down to scheme://host. It also dropped the upstream org namespace from ids whose first segment coincides with a known litellm provider (openai/gpt-oss-120b became openrouter/gpt-oss-120b) instead of keeping it (openrouter/openai/gpt-oss-120b). - gpt_transformation.get_models keeps the api_base path and only appends /models when the base already ends with /v1. - get_known_models_from_wildcard strips a leading provider segment only when it belongs to the same provider family as the expanded provider, so upstream org namespaces survive re-prefixing. Regression tests: - test_get_models_keeps_api_version_path / plain_host / trailing_slash - test_wildcard_openrouter_keeps_upstream_org_namespace - test_wildcard_custom_prefix_still_strips_same_family_alias Signed-off-by: apex-mochen <2756823972@qq.com>
This was referenced Oct 9, 2026
Contributor
Author
|
All 67 check runs are failing at the shared Could we get a re-run once the environment settles? |
Closed
4 of 7 tasks
9 tasks done
Contributor
|
Closing as superseded by #48820, which lists the OpenRouter catalog with vendor namespaces and the right path. Thanks for the early fix |
6 of 8 tasks
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.
Summary
Fixes #45506
OpenRouter wildcard model discovery is broken in two independent ways:
OpenrouterConfiginherits the OpenAI-compatibleget_models, which strippedapi_basedown toscheme://hostand thenrequested
/v1/models. With the documentedapi_base=https://openrouter.ai/api/v1, discovery requestedhttps://openrouter.ai/v1/models(404) instead ofhttps://openrouter.ai/api/v1/models.get_known_models_from_wildcardstripped the first slash segment of every id whose leading segment happens
to be a known litellm provider. OpenRouter's catalog returns ids that are
already org-namespaced (e.g.
openai/gpt-oss-120b), soopenrouter/*expanded to
openrouter/gpt-oss-120b— an uncallable id — instead ofopenrouter/openai/gpt-oss-120b.Changes
OpenAIGPTConfig.get_models: keep theapi_basepath; append/modelswhen the base already ends with
/v1, otherwise append/v1/models.Output for OpenAI's own base (
https://api.openai.com) is unchanged.get_known_models_from_wildcard: strip a leading provider segment only whenit belongs to the same provider family as the expanded provider
(
leading == provider,leading.startswith(f"{provider}_"), orprovider.startswith(f"{leading}_")), preserving upstream org namespaces.Regression tests
TestOpenAIGPTConfigGetModels(3 cases): keeps the api_version path,plain-host still resolves to
/v1/models, trailing slash normalized.test_wildcard_openrouter_keeps_upstream_org_namespace: openai/anthropic/meta-llama ids survive as
openrouter/<org>/<model>.test_wildcard_custom_prefix_still_strips_same_family_alias: the existingollama_server1/*+ollama_chat/*alias behaviour is preserved.Verification
ruff check/ruff format --checkclean on both source files.ruff check --config ruff-tests.tomlclean on both test files.test_model_checks.py: 40 passed.test_openai_gpt_transformation.py -k GetModels: 3 passed.AI-assisted disclosure: code and tests were produced with AI assistance and
reviewed by the author.