diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index 61a73201c43..932930dc6a0 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -218,7 +218,7 @@ def get_llm_provider( dynamic_api_key=dynamic_api_key, litellm_params=litellm_params, ) - elif model.split("/", 1)[0] in litellm.provider_list: + elif model.split("/", 1)[0] in litellm.provider_list and len(model.split("/")) > 1: custom_llm_provider = model.split("/", 1)[0] model = model.split("/", 1)[1] if api_base is not None and not isinstance(api_base, str): diff --git a/tests/test_litellm/litellm_core_utils/test_get_llm_provider_logic.py b/tests/test_litellm/litellm_core_utils/test_get_llm_provider_logic.py new file mode 100644 index 00000000000..259355d83a4 --- /dev/null +++ b/tests/test_litellm/litellm_core_utils/test_get_llm_provider_logic.py @@ -0,0 +1,12 @@ +import pytest + +import litellm + + +@pytest.mark.parametrize("model", ["mistral", "openai", "anthropic", "groq", "deepseek"]) +def test_get_llm_provider_bare_provider_name_raises_helpful_error(model): + with pytest.raises(litellm.BadRequestError) as exc_info: + litellm.get_llm_provider(model=model) + message = str(exc_info.value) + assert "LLM Provider NOT provided" in message + assert "list index out of range" not in message