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: Support batch requests with comma-separated models in validate_model_access (#18909)
akraines7e6d0d7691ec
diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.pyindex 171898b1631..9ea2ea7d5c9 100644--- a/litellm/proxy/utils.py+++ b/litellm/proxy/utils.py@@ -4479,21 +4479,35 @@ def validate_model_access() -> None:"""Validate that a model is accessible to the user.+ Supports batch requests with comma-separated model IDs.Args:- model_id: The model ID to validate+ model_id: The model ID to validate (can be comma-separated for batch requests)available_models: List of models available to the userRaises:HTTPException: If the model is not accessible"""- if model_id not in available_models:- raise HTTPException(- status_code=404,- detail="The model `{}` does not exist or is not accessible".format(- model_id- ),- )+ # Handle batch requests with comma-separated models+ if "," in model_id:+ models = [m.strip() for m in model_id.split(",")]+ inaccessible_models = [m for m in models if m not in available_models]+ if inaccessible_models:+ raise HTTPException(+ status_code=404,+ detail="The following model(s) do not exist or are not accessible: {}".format(+ ", ".join(inaccessible_models)+ ),+ )+ else:+ # Single model validation+ if model_id not in available_models:+ raise HTTPException(+ status_code=404,+ detail="The model `{}` does not exist or is not accessible".format(+ model_id+ ),+ )def _path_matches_pattern(path: str, pattern: str) -> bool: