diff --git a/litellm/proxy/auth/model_checks.py b/litellm/proxy/auth/model_checks.py index 55b4670d14e..fb925a3b133 100644 --- a/litellm/proxy/auth/model_checks.py +++ b/litellm/proxy/auth/model_checks.py @@ -325,7 +325,7 @@ def get_known_models_from_wildcard(wildcard_model: str, litellm_params: LiteLLM_ # Only strip the leading segment when it is a known provider, so ids whose first # segment is an org rather than a provider (e.g. "meta-llama/Llama-3-8B") keep it. leading, sep, model_suffix = model.partition("/") - if sep and leading in known_providers: + if sep and leading in known_providers and (provider in litellm.models_by_provider or leading == provider): model = f"{wildcard_provider_prefix}/{model_suffix}" else: model = f"{wildcard_provider_prefix}/{model}" diff --git a/tests/test_litellm/proxy/auth/test_model_checks.py b/tests/test_litellm/proxy/auth/test_model_checks.py index 451f4eac9a0..bea46a3fd23 100644 --- a/tests/test_litellm/proxy/auth/test_model_checks.py +++ b/tests/test_litellm/proxy/auth/test_model_checks.py @@ -442,6 +442,7 @@ def test_get_known_models_from_wildcard_hosted_vllm_uses_provider_endpoint(): "data": [ {"id": "meta-llama/Llama-3.1-8B-Instruct"}, {"id": "qwen2.5"}, + {"id": "openai/foo"}, ] } original_check_provider_endpoint = litellm.check_provider_endpoint @@ -460,6 +461,7 @@ def test_get_known_models_from_wildcard_hosted_vllm_uses_provider_endpoint(): assert result == [ "hosted_vllm/meta-llama/Llama-3.1-8B-Instruct", "hosted_vllm/qwen2.5", + "hosted_vllm/openai/foo", ]