diff --git a/tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py b/tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py index 8df35a37514..7be4d6dfcf2 100644 --- a/tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py +++ b/tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py @@ -30,6 +30,19 @@ class TestAzureOpenAIConfig: assert not config._is_response_format_supported_model("gpt-35-turbo") + def test_prompt_cache_key_supported(self): + """Test that 'prompt_cache_key' is in supported params for Azure OpenAI chat completion models. + + OpenAI's Chat Completions API supports prompt_cache_key for cache routing optimization. + """ + config = AzureOpenAIConfig() + supported_params = config.get_supported_openai_params("gpt-4.1-nano") + assert "prompt_cache_key" in supported_params + + supported_params = config.get_supported_openai_params("gpt-4.1") + assert "prompt_cache_key" in supported_params + + def test_map_openai_params_with_preview_api_version(): config = AzureOpenAIConfig() non_default_params = { diff --git a/tests/test_litellm/llms/openai/chat/test_openai_gpt_transformation.py b/tests/test_litellm/llms/openai/chat/test_openai_gpt_transformation.py index 5f087363797..c0695bf3588 100644 --- a/tests/test_litellm/llms/openai/chat/test_openai_gpt_transformation.py +++ b/tests/test_litellm/llms/openai/chat/test_openai_gpt_transformation.py @@ -2,9 +2,10 @@ Tests for OpenAI GPT transformation (litellm/llms/openai/chat/gpt_transformation.py) """ -import pytest -import sys import os +import sys + +import pytest sys.path.insert(0, os.path.abspath("../../../../..")) @@ -73,6 +74,17 @@ class TestOpenAIGPTConfig: for param in base_expected_params: assert param in supported_params, f"Expected '{param}' in supported params" + def test_prompt_cache_key_supported(self): + """Test that 'prompt_cache_key' is in supported params for OpenAI chat completion models. + + OpenAI's Chat Completions API supports prompt_cache_key for cache routing optimization. + """ + supported_params = self.config.get_supported_openai_params("gpt-4.1-nano") + assert "prompt_cache_key" in supported_params + + supported_params = self.config.get_supported_openai_params("gpt-4.1") + assert "prompt_cache_key" in supported_params + class TestGetOptionalParamsIntegration: """Integration tests using litellm.get_optional_params()""" @@ -123,3 +135,14 @@ class TestGetOptionalParamsIntegration: # Both should include user assert regular_params.get("user") == "my-end-user" assert responses_params.get("user") == "my-end-user" + + def test_prompt_cache_key_in_optional_params(self): + """Test that 'prompt_cache_key' flows through get_optional_params for OpenAI models.""" + from litellm.utils import get_optional_params + + optional_params = get_optional_params( + model="gpt-4.1-nano", + custom_llm_provider="openai", + prompt_cache_key="test-cache-key-123", + ) + assert optional_params.get("prompt_cache_key") == "test-cache-key-123"