This commit is contained in:
Abdullah Habib Biswas 2026-08-27 16:14:34 -05:00 committed by GitHub
commit e727d1bc9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View file

@ -31,6 +31,7 @@ class CacheControlSupportedModels(str, Enum):
MINIMAX = "minimax"
GLM = "glm"
ZAI = "z-ai"
QWEN = "qwen"
class OpenrouterConfig(OpenAIGPTConfig):
@ -45,6 +46,11 @@ class OpenrouterConfig(OpenAIGPTConfig):
):
supported_params.append("reasoning_effort")
supported_params.append("thinking")
if self._supports_cache_control_in_content(model):
supported_params.append("cache_control")
supported_params.append("cache_control_injection_points")
except Exception:
pass
return list(dict.fromkeys(supported_params))

View file

@ -40,3 +40,25 @@ def test_openrouter_embedding():
assert resp.data[0]["embedding"] is not None
assert isinstance(resp.data[0]["embedding"], list)
assert len(resp.data[0]["embedding"]) > 0
def test_openrouter_qwen_cache_control_supported():
"""
Validates that Qwen models routed through OpenRouter cleanly support
cache_control and cache_control_injection_points parameters,
resolving issue #29322.
"""
from litellm.llms.openrouter.chat.transformation import OpenrouterConfig
config = OpenrouterConfig()
qwen_model = "openrouter/qwen/qwen3.6-flash"
# Retrieve the dynamically mapped parameters for the Qwen endpoint
supported_params = config.get_supported_openai_params(model=qwen_model)
# Assertions to ensure the translation layer captures the caching parameters
assert "cache_control" in supported_params, f"cache_control missing from supported parameters for {qwen_model}"
assert "cache_control_injection_points" in supported_params, f"cache_control_injection_points missing from supported parameters for {qwen_model}"
print("✅ test_openrouter_qwen_cache_control_supported passed!")