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]

test test_default_tagged_deployments

Ishaan Jafffe7ab3f3d7c4
diff --git a/litellm/tests/test_router_tag_routing.py b/litellm/tests/test_router_tag_routing.py
index 67f100d7945..4da109a136e 100644
--- a/litellm/tests/test_router_tag_routing.py
+++ b/litellm/tests/test_router_tag_routing.py
@@ -91,3 +91,64 @@ async def test_router_free_paid_tier():
print("response_extra_info: ", response_extra_info)
assert response_extra_info["model_id"] == "very-expensive-model"
+
+
+async def test_default_tagged_deployments():
+ """
+ - only use default deployment for untagged requests
+ - if a request has tag "default", use default deployment
+ """
+
+ router = litellm.Router(
+ model_list=[
+ {
+ "model_name": "gpt-4",
+ "litellm_params": {
+ "model": "gpt-4o",
+ "api_base": "https://exampleopenaiendpoint-production.up.railway.app/",
+ "tags": ["default"],
+ },
+ "model_info": {"id": "default-model"},
+ },
+ {
+ "model_name": "gpt-4",
+ "litellm_params": {
+ "model": "gpt-4o-mini",
+ "api_base": "https://exampleopenaiendpoint-production.up.railway.app/",
+ "tags": ["teamA"],
+ },
+ "model_info": {"id": "very-expensive-model"},
+ },
+ ],
+ enable_tag_filtering=True,
+ )
+
+ for _ in range(5):
+ # Untagged request, this should pick model with id == "default-model"
+ response = await router.acompletion(
+ model="gpt-4",
+ messages=[{"role": "user", "content": "Tell me a joke."}],
+ )
+
+ print("Response: ", response)
+
+ response_extra_info = response._hidden_params
+ print("response_extra_info: ", response_extra_info)
+
+ assert response_extra_info["model_id"] == "default-model"
+
+ for _ in range(5):
+ # requests tagged with "default", this should pick model with id == "default-model"
+ response = await router.acompletion(
+ model="gpt-4",
+ messages=[{"role": "user", "content": "Tell me a joke."}],
+ metadata={"tags": ["default"]},
+ )
+
+ print("Response: ", response)
+
+ response_extra_info = response._hidden_params
+ print("response_extra_info: ", response_extra_info)
+
+ assert response_extra_info["model_id"] == "default-model"