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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(router): keep silent_model out of embedding provider requests (#44064)
devin-ai-integration[bot]ba8cd1ee3159
diff --git a/litellm/types/litellm_params.py b/litellm/types/litellm_params.pyindex 20214078852..51f6671e9d6 100644--- a/litellm/types/litellm_params.py+++ b/litellm/types/litellm_params.py@@ -151,6 +151,7 @@ class DeploymentOptions:order: int | None = Nonetag_regex: Sequence[str] | None = Nonemax_file_size_mb: float | None = None+ silent_model: str | Sequence[str] | None = None@dataclass(frozen=True, slots=True, kw_only=True)diff --git a/tests/unit/test_router_silent_experiment.py b/tests/unit/test_router_silent_experiment.pyindex 722a76fa7ef..e184164d009 100644--- a/tests/unit/test_router_silent_experiment.py+++ b/tests/unit/test_router_silent_experiment.py@@ -1,11 +1,14 @@import asyncio+import jsonimport timefrom collections.abc import Callable, Mappingfrom types import SimpleNamespacefrom typing import Finalfrom unittest.mock import AsyncMock, MagicMock, patch+import httpximport pytest+import respximport litellmfrom litellm.integrations.custom_logger import CustomLogger@@ -603,6 +606,67 @@ def test_silent_experiment_sends_shadow_request_attributed_to_the_silent_model(rassert primary_metadata == {"model_group": "primary-model"}+++_EMBEDDING_API_BASE: Final = "https://embeddings.example.test/v1"+++def _strict_embedding_route(respx_mock: respx.MockRouter) -> respx.Route:+ return respx_mock.post(f"{_EMBEDDING_API_BASE}/embeddings").mock(+ return_value=httpx.Response(+ 200,+ json={+ "object": "list",+ "data": [{"object": "embedding", "index": 0, "embedding": [0.1, 0.2]}],+ "model": "embed-model",+ "usage": {"prompt_tokens": 2, "total_tokens": 2},+ },+ )+ )+++def _embedding_router_with_silent_model() -> Router:+ return Router(+ model_list=[+ {+ "model_name": "embed-primary",+ "litellm_params": {+ "model": "openai/embed-model",+ "api_base": _EMBEDDING_API_BASE,+ "api_key": "fake-key",+ "silent_model": "embed-shadow",+ },+ }+ ]+ )+++def test_embedding_with_silent_model_sends_provider_body_without_it(respx_mock: respx.MockRouter) -> None:+ route: Final = _strict_embedding_route(respx_mock)++ response: Final = _embedding_router_with_silent_model().embedding(+ model="embed-primary", input=["black dresses"], input_type="query"+ )++ request_body: Final = json.loads(route.calls.last.request.read())+ assert request_body == {"model": "embed-model", "input": ["black dresses"], "input_type": "query"}+ assert response.data[0]["embedding"] == [0.1, 0.2]+++async def test_aembedding_with_silent_model_sends_provider_body_without_it(+ respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch+) -> None:+ monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)+ route: Final = _strict_embedding_route(respx_mock)++ response: Final = await _embedding_router_with_silent_model().aembedding(+ model="embed-primary", input=["black dresses"], input_type="query"+ )++ request_body: Final = json.loads(route.calls.last.request.read())+ assert request_body == {"model": "embed-model", "input": ["black dresses"], "input_type": "query"}+ assert response.data[0]["embedding"] == [0.1, 0.2]@pytest.mark.parametrize("run_silent_experiment", SILENT_EXPERIMENT_RUNNERS)def test_silent_experiment_does_not_launch_from_a_shadow_request(run_silent_experiment):router = Router(model_list=_streaming_model_list(["shadow-a"]))diff --git a/tests/unit/types/test_litellm_params.py b/tests/unit/types/test_litellm_params.pyindex 16ae6b963d0..e3bbae39468 100644--- a/tests/unit/types/test_litellm_params.py+++ b/tests/unit/types/test_litellm_params.py@@ -129,6 +129,7 @@ OPTION_NAMES: Final = ("order","tag_regex","max_file_size_mb",+ "silent_model","auto_router_config_path","auto_router_config","auto_router_default_model",