diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 272fbabf807..d0feec383bd 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3519,6 +3519,7 @@ all_litellm_params = ( "litellm_session_id", "use_litellm_proxy", "use_chat_completions_api", + "rust", "prompt_label", "shared_session", "search_tool_name", diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.py index 661b6ed7244..2b0b8b6ab20 100644 --- a/tests/test_litellm/test_utils.py +++ b/tests/test_litellm/test_utils.py @@ -4795,3 +4795,49 @@ def test_bedrock_batch_params_never_reach_the_provider(): "credential normalization dropped batch params before the transformation: " f"{sorted(f for f in bedrock_batch_litellm_params if normalized.get(f) != configured[f])}" ) + + +def test_rust_flag_not_forwarded_as_provider_param(): + forwarded = get_non_default_completion_params({"rust": True, "temperature": 0.5}) + assert "rust" not in forwarded + + +def test_completion_does_not_leak_rust_flag_into_provider_request_body(): + mock_response = MagicMock() + mock_response.model_dump.return_value = { + "id": "chatcmpl-1", + "object": "chat.completion", + "created": 1234567890, + "model": "gpt-4o-mini", + "choices": [ + { + "index": 0, + "message": {"role": "assistant", "content": "hi"}, + "finish_reason": "stop", + } + ], + "usage": { + "prompt_tokens": 1, + "completion_tokens": 1, + "total_tokens": 2, + }, + } + + mock_raw_response = MagicMock() + mock_raw_response.headers = {} + mock_raw_response.parse.return_value = mock_response + + mock_client = MagicMock() + mock_client.chat.completions.with_raw_response.create.return_value = mock_raw_response + + litellm.completion( + model="openai/gpt-4o-mini", + messages=[{"role": "user", "content": "hi"}], + rust=True, + api_key="sk-test", + client=mock_client, + ) + + create_kwargs = mock_client.chat.completions.with_raw_response.create.call_args.kwargs + assert "rust" not in create_kwargs + assert "rust" not in (create_kwargs.get("extra_body") or {}) diff --git a/tests/test_litellm/types/test_types_utils.py b/tests/test_litellm/types/test_types_utils.py index a446f820870..cd5e8dda012 100644 --- a/tests/test_litellm/types/test_types_utils.py +++ b/tests/test_litellm/types/test_types_utils.py @@ -5,7 +5,11 @@ import pytest sys.path.insert(0, os.path.abspath("../..")) -from litellm.types.utils import HiddenParams +from litellm.types.utils import HiddenParams, all_litellm_params + + +def test_rust_is_a_known_litellm_param(): + assert "rust" in all_litellm_params def test_hidden_params_response_ms():