From e7176cc1052ac74ef87e42e14eec3c042af45aab Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Thu, 10 Sep 2026 19:24:04 +0530 Subject: [PATCH] fix: stop forwarding litellm_params into the provider request body litellm_params was not listed in all_litellm_params, so the OpenAI param builder treated it as provider configuration and swept it into the outbound request. Bedrock Converse rejects the unknown field with unknown_parameter: litellm_params, and other providers receive the credentials it carries. Fixes #40072 --- litellm/types/utils.py | 1 + tests/test_litellm/types/test_types_utils.py | 39 +++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index ab0cc5f959c..fdd0715be6b 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3683,6 +3683,7 @@ all_litellm_params = ( + [ "metadata", "litellm_metadata", + "litellm_params", "keepalive_seconds", "allow_client_keepalive_override", "litellm_trace_id", diff --git a/tests/test_litellm/types/test_types_utils.py b/tests/test_litellm/types/test_types_utils.py index 5f44ba1773e..f7e8cc45071 100644 --- a/tests/test_litellm/types/test_types_utils.py +++ b/tests/test_litellm/types/test_types_utils.py @@ -1,8 +1,9 @@ from typing import Final +from unittest.mock import MagicMock import pytest - +import litellm from litellm.types.utils import HiddenParams, all_litellm_params, text_tokens_without_nested_reasoning @@ -10,6 +11,42 @@ def test_rust_is_a_known_litellm_param(): assert "rust" in all_litellm_params +def test_litellm_params_is_not_sent_to_the_provider(): + """https://github.com/BerriAI/litellm/issues/40072""" + parsed: Final = MagicMock() + parsed.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}, + } + raw_response: Final = MagicMock() + raw_response.headers = {} + raw_response.parse.return_value = parsed + client: Final = MagicMock() + client.chat.completions.with_raw_response.create.return_value = raw_response + + litellm.completion( + model="openai/gpt-4o-mini", + messages=[{"role": "user", "content": "hi"}], + litellm_params={"api_key": "sk-deployment-credential"}, + api_key="sk-test", + client=client, + ) + + create_kwargs: Final = client.chat.completions.with_raw_response.create.call_args.kwargs + assert "litellm_params" not in create_kwargs + assert "litellm_params" not in (create_kwargs.get("extra_body") or {}) + + def test_hidden_params_response_ms(): hidden_params = HiddenParams() setattr(hidden_params, "_response_ms", 100)