This commit is contained in:
Abdullah Habib Biswas 2026-09-08 07:04:32 -04:00 committed by GitHub
commit f18b2e5fe3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View file

@ -36,6 +36,7 @@ class CacheControlSupportedModels(str, Enum):
MINIMAX = "minimax"
GLM = "glm"
ZAI = "z-ai"
QWEN = "qwen"
class OpenrouterConfig(OpenAIGPTConfig):
@ -50,6 +51,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!")