diff --git a/litellm/main.py b/litellm/main.py index ddd37b47536..5356c6f3642 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -4797,7 +4797,9 @@ def embedding( # noqa: PLR0915 } ) - litellm_params_dict = get_litellm_params(**kwargs) + litellm_params_dict = get_litellm_params( + custom_llm_provider=custom_llm_provider, **kwargs + ) logging: LiteLLMLoggingObj = litellm_logging_obj # type: ignore logging.update_environment_variables( @@ -6488,7 +6490,9 @@ def transcription( **non_default_params, ) - litellm_params_dict = get_litellm_params(**kwargs) + litellm_params_dict = get_litellm_params( + custom_llm_provider=custom_llm_provider, **kwargs + ) litellm_logging_obj.update_environment_variables( model=model, @@ -6717,7 +6721,9 @@ def speech( # noqa: PLR0915 if max_retries is None: max_retries = litellm.num_retries or openai.DEFAULT_MAX_RETRIES - litellm_params_dict = get_litellm_params(**kwargs) + litellm_params_dict = get_litellm_params( + custom_llm_provider=custom_llm_provider, **kwargs + ) # Get provider-specific text-to-speech config and map parameters text_to_speech_provider_config = ( diff --git a/tests/test_litellm/litellm_core_utils/test_get_litellm_params.py b/tests/test_litellm/litellm_core_utils/test_get_litellm_params.py index b39943b3e49..633a3ad2e84 100644 --- a/tests/test_litellm/litellm_core_utils/test_get_litellm_params.py +++ b/tests/test_litellm/litellm_core_utils/test_get_litellm_params.py @@ -95,6 +95,30 @@ class TestGetLitellmParamsBaseModel: assert result["base_model"] is None +class TestGetLitellmParamsCustomLlmProvider: + """Verify custom_llm_provider handling — explicit value vs kwargs.""" + + def test_explicit_custom_llm_provider(self): + """Explicit custom_llm_provider should appear in result.""" + result = get_litellm_params(custom_llm_provider="hosted_vllm") + assert result["custom_llm_provider"] == "hosted_vllm" + + def test_custom_llm_provider_not_in_kwargs(self): + """When custom_llm_provider is not passed, it defaults to None. + + This mirrors the bug in embedding()/transcription()/speech() where + custom_llm_provider was extracted as a named parameter and thus + removed from **kwargs before being passed to get_litellm_params(). + """ + result = get_litellm_params(**{"api_key": "test"}) + assert result["custom_llm_provider"] is None + + def test_explicit_custom_llm_provider_with_kwargs(self): + """Explicit custom_llm_provider should not be overridden by kwargs.""" + result = get_litellm_params(custom_llm_provider="hosted_vllm", api_key="test") + assert result["custom_llm_provider"] == "hosted_vllm" + + class TestGetLitellmParamsExplicitFields: """Verify explicit parameters are always present in the result.""" @@ -125,4 +149,3 @@ class TestGetLitellmParamsExplicitFields: def test_no_log_from_explicit_param(self): result = get_litellm_params(no_log=True) assert result["no-log"] is True -