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(proxy): preserve metadata for public team aliases

Hayden Moulds49809a814bf6
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index 0f24acb8bb4..ccabc4ed572 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -10827,14 +10827,15 @@ async def model_info(
# Use the actual litellm model from the deployment to get provider info
_, provider, _, _ = litellm.get_llm_provider(model=deployment.litellm_params.model)
- response_id: Final = internal_to_public.get(resolved_model_id, model_id)
- return create_model_info_response(
- model_id=response_id,
+ response = create_model_info_response(
+ model_id=resolved_model_id,
provider=provider,
include_metadata=False,
fallback_type=None,
llm_router=llm_router,
)
+ response["id"] = internal_to_public.get(resolved_model_id, model_id)
+ return response
def _blocked_response_usage(original_response: object | None) -> "litellm.Usage":
diff --git a/tests/test_litellm/proxy/proxy_server/test_team_alias_listing_metadata.py b/tests/test_litellm/proxy/proxy_server/test_team_alias_listing_metadata.py
new file mode 100644
index 00000000000..ce637d2e19f
--- /dev/null
+++ b/tests/test_litellm/proxy/proxy_server/test_team_alias_listing_metadata.py
@@ -0,0 +1,94 @@
+"""Regression coverage for metadata on public team model aliases."""
+
+from unittest.mock import MagicMock
+
+import pytest
+
+import litellm.proxy.proxy_server as ps
+from litellm.proxy._types import UserAPIKeyAuth
+from litellm.types.router import DeploymentModelListingInfo
+
+
+def _team_router(*, public_name: str, internal_name: str, underlying_model: str, listing_info):
+ deployment = {
+ "model_name": internal_name,
+ "litellm_params": {"model": underlying_model},
+ "model_info": {
+ "id": "deployment-id",
+ "team_id": "teamx",
+ "team_public_model_name": public_name,
+ "access_groups": ["team-access"],
+ },
+ }
+ router = MagicMock()
+ router.get_model_names.return_value = [internal_name]
+ router.get_model_access_groups.return_value = {"team-access": [internal_name]}
+ router.get_fully_blocked_model_names.return_value = set()
+ router.get_model_listing_info.return_value = listing_info
+ router.get_model_group_info.return_value = None
+ router.model_list = [deployment]
+ router.get_model_list.return_value = [deployment]
+ return router
+
+
+async def test_team_alias_inherits_deployment_token_limits_and_chat_mode(monkeypatch):
+ router = _team_router(
+ public_name="GPT Terra",
+ internal_name="model_name_teamx_terra_uuid",
+ underlying_model="azure/gpt-4.1",
+ listing_info=DeploymentModelListingInfo(
+ cost_map_keys=("azure/gpt-4.1",),
+ max_input_tokens=876000,
+ max_output_tokens=128000,
+ ),
+ )
+ monkeypatch.setattr(ps, "llm_router", router)
+ monkeypatch.setattr(ps, "user_model", None)
+ monkeypatch.setattr(ps, "general_settings", {"use_team_public_model_name": True})
+
+ key = UserAPIKeyAuth(user_id="user", api_key="***", models=["team-access"], team_models=[])
+ response = await ps.model_list(user_api_key_dict=key, include_metadata=True)
+
+ assert response["data"] == [
+ {
+ "id": "GPT Terra",
+ "object": "model",
+ "created": 1677610602,
+ "owned_by": "openai",
+ "mode": "chat",
+ "max_input_tokens": 876000,
+ "max_output_tokens": 128000,
+ "metadata": {"fallbacks": []},
+ }
+ ]
+
+
+async def test_team_image_alias_inherits_image_generation_mode(monkeypatch):
+ router = _team_router(
+ public_name="image",
+ internal_name="model_name_teamx_image_uuid",
+ underlying_model="openai/gpt-image-1",
+ listing_info=DeploymentModelListingInfo(
+ cost_map_keys=("openai/gpt-image-1",),
+ max_input_tokens=None,
+ max_output_tokens=None,
+ ),
+ )
+ monkeypatch.setattr(ps, "llm_router", router)
+ monkeypatch.setattr(ps, "user_model", None)
+ monkeypatch.setattr(ps, "general_settings", {"use_team_public_model_name": True})
+
+ key = UserAPIKeyAuth(user_id="user", api_key="***", models=["team-access"], team_models=[])
+ response = await ps.model_list(user_api_key_dict=key)
+
+ assert response["data"] == [
+ {
+ "id": "image",
+ "object": "model",
+ "created": 1677610602,
+ "owned_by": "openai",
+ "mode": "image_generation",
+ }
+ ]