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
This commit is contained in:
Animesh Kumar 2026-09-10 19:24:04 +05:30
parent e5da59336d
commit e7176cc105
2 changed files with 39 additions and 1 deletions

View file

@ -3683,6 +3683,7 @@ all_litellm_params = (
+ [
"metadata",
"litellm_metadata",
"litellm_params",
"keepalive_seconds",
"allow_client_keepalive_override",
"litellm_trace_id",

View file

@ -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)