Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(litellm_proxy): forward tool_config cache_control_injection_points to the downstream proxy (#47570)

Kerry Lu04e9ed4c5250
diff --git a/litellm/utils.py b/litellm/utils.py
index 14ee35e571e..a6108a15bb3 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -5552,8 +5552,9 @@ def add_provider_specific_params_to_optional_params(
# for openai, azure we should pass the extra/passed params within `extra_body` https://github.com/openai/openai-python/blob/ac33853ba10d13ac149b1fa3ca6dba7d613065c9/src/openai/resources/models.py#L46
if _should_drop_param(k="extra_body", additional_drop_params=additional_drop_params) is False:
extra_body: Final = dict(passed_params.pop("extra_body", None) or {})
+ withheld_params: Final = frozenset[str]() if custom_llm_provider == "litellm_proxy" else LITELLM_ONLY_PARAMS
for k in passed_params:
- if k not in openai_params and k not in LITELLM_ONLY_PARAMS and passed_params[k] is not None:
+ if k not in openai_params and k not in withheld_params and passed_params[k] is not None:
extra_body[k] = passed_params[k]
if not isinstance(optional_params.get("extra_body"), dict):
optional_params["extra_body"] = {}
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index 44939ca7585..0be3ae05e97 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -10703,3 +10703,18 @@ def test_get_optional_params_keeps_a_tool_config_cache_point_out_of_the_openai_e
assert optional_params["extra_body"] == {"kept": True}
assert "cache_control_injection_points" not in optional_params
+
+
+def test_get_optional_params_forwards_a_tool_config_cache_point_to_a_downstream_litellm_proxy():
+ """A litellm_proxy deployment calls the downstream proxy through the OpenAI SDK, and that proxy
+ applies cache_control_injection_points itself, so the point must ride along in extra_body."""
+ point: Final = {"location": "tool_config", "control": {"type": "ephemeral"}}
+ optional_params: Final[dict[str, object]] = litellm.utils.get_optional_params(
+ model="claude-sonnet-4-5",
+ custom_llm_provider="litellm_proxy",
+ tools=[{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object"}}}],
+ cache_control_injection_points=[point],
+ extra_body={"kept": True},
+ )
+
+ assert optional_params["extra_body"] == {"kept": True, "cache_control_injection_points": [point]}