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): resolve team wildcard credentials for vector store files

Shivam Rawatbea11ddedd41
diff --git a/litellm/proxy/vector_store_files_endpoints/endpoints.py b/litellm/proxy/vector_store_files_endpoints/endpoints.py
index 890db2f73a4..44935fc57c9 100644
--- a/litellm/proxy/vector_store_files_endpoints/endpoints.py
+++ b/litellm/proxy/vector_store_files_endpoints/endpoints.py
@@ -227,6 +227,8 @@ async def _update_request_data_with_model_routing_hint(
model_hint = data.get("model") or user_controlled_model_hint
should_authorize_model_hint = isinstance(model_hint, str) and model_hint == user_controlled_model_hint
+ caller_team_id = getattr(user_api_key_dict, "team_id", None) if user_api_key_dict else None
+
should_route = False
credentials = None
if isinstance(model_hint, str) and "*" in model_hint:
@@ -237,7 +239,9 @@ async def _update_request_data_with_model_routing_hint(
llm_router=llm_router,
user_api_key_dict=user_api_key_dict,
)
- credentials = llm_router.get_deployment_credentials_with_provider(model_id=model_hint)
+ credentials = llm_router.get_deployment_credentials_with_provider(
+ model_id=model_hint, team_id=caller_team_id
+ )
should_route = credentials is not None
else:
if isinstance(model_hint, str) and should_authorize_model_hint:
@@ -285,7 +289,7 @@ async def _update_request_data_with_model_routing_hint(
openai_credentials = None
for model_name in model_names_to_check:
- credentials = llm_router.get_deployment_credentials_with_provider(model_id=model_name)
+ credentials = llm_router.get_deployment_credentials_with_provider(model_id=model_name, team_id=caller_team_id)
if credentials is None:
continue
diff --git a/litellm/router.py b/litellm/router.py
index 78e156801f8..dbc6da106e7 100644
--- a/litellm/router.py
+++ b/litellm/router.py
@@ -8459,7 +8459,9 @@ class Router:
raise Exception("Model Name invalid - {}".format(type(model)))
return None
- def get_deployment_credentials_with_provider(self, model_id: str) -> Optional[Dict[str, Any]]:
+ def get_deployment_credentials_with_provider(
+ self, model_id: str, team_id: Optional[str] = None
+ ) -> Optional[Dict[str, Any]]:
"""
Get API credentials and provider info from a model name in model_list.
Useful for passthrough endpoints (files, batches, etc.) that need credentials.
@@ -8469,6 +8471,9 @@ class Router:
Args:
model_id: Model ID or model name from model_list (e.g., "gpt-4o-litellm")
+ team_id: Optional team id of the caller. When set, team-scoped
+ deployments (indexed by team public model name, including team
+ wildcard models like "openai/*") are also considered.
Returns:
Dictionary containing api_key, api_base, custom_llm_provider, etc.
@@ -8487,9 +8492,19 @@ class Router:
if deployment is None:
deployment = self.get_deployment_by_model_group_name(model_group_name=model_id)
+ # If not found, check team-scoped deployments (team public model names,
+ # e.g. team wildcard models like "openai/*", live in a separate index).
+ if deployment is None and team_id is not None:
+ team_indices = self.team_model_to_deployment_indices.get((team_id, model_id), [])
+ if team_indices:
+ team_model = self.model_list[team_indices[0]]
+ deployment = Deployment(**team_model) if isinstance(team_model, dict) else team_model
+
# If still not found, check for wildcard pattern matches
if deployment is None:
potential_wildcard_models = self.pattern_router.route(model_id) or []
+ if not potential_wildcard_models and team_id is not None and team_id in self.team_pattern_routers:
+ potential_wildcard_models = self.team_pattern_routers[team_id].route(model_id) or []
if potential_wildcard_models:
# Use the first matching wildcard deployment
deployment_dict = potential_wildcard_models[0]