test_prompt_cache_key_supported

This commit is contained in:
Ishaan Jaffer 2026-02-11 11:51:49 -08:00
parent 658cd7e139
commit 739000e202
2 changed files with 38 additions and 2 deletions

View file

@ -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 = {

View file

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