From 9e1d83e3de5d94addd25e03e12afda2bbeffd2b5 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Sat, 21 Feb 2026 13:25:23 -0800 Subject: [PATCH] fix: make LITELLM_CLIENT_SPECIFIC_PARAMS a tuple to prevent TypeError tuple + list raises TypeError in get_openai_client_cache_key. Also add test coverage for get_openai_client_cache_key to catch type mismatches. --- litellm/llms/openai/common_utils.py | 4 ++-- .../llms/openai/test_openai_common_utils.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/litellm/llms/openai/common_utils.py b/litellm/llms/openai/common_utils.py index a89f7f9c2b..a05482c800 100644 --- a/litellm/llms/openai/common_utils.py +++ b/litellm/llms/openai/common_utils.py @@ -168,12 +168,12 @@ class BaseOpenAILLM: f"is_async={client_initialization_params.get('is_async')}", ] - LITELLM_CLIENT_SPECIFIC_PARAMS = [ + LITELLM_CLIENT_SPECIFIC_PARAMS = ( "timeout", "max_retries", "organization", "api_base", - ] + ) openai_client_fields = ( BaseOpenAILLM.get_openai_client_initialization_param_fields( client_type=client_type diff --git a/tests/test_litellm/llms/openai/test_openai_common_utils.py b/tests/test_litellm/llms/openai/test_openai_common_utils.py index d0dedd3ed9..8489040660 100644 --- a/tests/test_litellm/llms/openai/test_openai_common_utils.py +++ b/tests/test_litellm/llms/openai/test_openai_common_utils.py @@ -164,3 +164,14 @@ def test_get_openai_client_initialization_param_fields(client_type): assert isinstance(result, tuple) assert len(result) > 0 assert "self" not in result + + +@pytest.mark.parametrize("client_type", ["openai", "azure"]) +def test_get_openai_client_cache_key(client_type): + """Verify get_openai_client_cache_key doesn't raise on tuple + tuple concatenation.""" + key = BaseOpenAILLM.get_openai_client_cache_key( + client_initialization_params={"api_key": "sk-test"}, + client_type=client_type, + ) + assert isinstance(key, str) + assert "api_key=sk-test" in key