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]

Litellm dev 05 19 2025 p3 (#10965)

Krish Dholakia6cfb6e525391
diff --git a/enterprise/enterprise_hooks/__init__.py b/enterprise/enterprise_hooks/__init__.py
index fa51e454625..830d97886a6 100644
--- a/enterprise/enterprise_hooks/__init__.py
+++ b/enterprise/enterprise_hooks/__init__.py
@@ -4,19 +4,12 @@ from typing import Dict, Literal, Type, Union
from litellm.integrations.custom_logger import CustomLogger
from .managed_files import _PROXY_LiteLLMManagedFiles
-from .parallel_request_limiter_v2 import _PROXY_MaxParallelRequestsHandler
ENTERPRISE_PROXY_HOOKS: Dict[str, Type[CustomLogger]] = {
"managed_files": _PROXY_LiteLLMManagedFiles,
}
-## FEATURE FLAG HOOKS ##
-
-if os.getenv("EXPERIMENTAL_MULTI_INSTANCE_RATE_LIMITING", "false").lower() == "true":
- ENTERPRISE_PROXY_HOOKS["max_parallel_requests"] = _PROXY_MaxParallelRequestsHandler
-
-
def get_enterprise_proxy_hook(
hook_name: Union[
Literal[
diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml
index 98d09d7f8da..a356818c85c 100644
--- a/litellm/proxy/_new_secret_config.yaml
+++ b/litellm/proxy/_new_secret_config.yaml
@@ -6,6 +6,8 @@ model_list:
litellm_params:
model: gpt-4o-mini
api_key: os.environ/OPENAI_API_KEY
+ model_info:
+ access_groups: ["default-openai-models"]
- model_name: "gpt-4o-realtime-preview"
litellm_params:
model: gpt-4o-realtime-preview-2024-10-01
@@ -72,3 +74,4 @@ model_list:
model_info:
id: my-unique-azure-deployment
mode: batch
+ access_groups: ["beta-models"]
\ No newline at end of file
diff --git a/litellm/proxy/auth/model_checks.py b/litellm/proxy/auth/model_checks.py
index 87eafd1eb1a..c5d2d4cf184 100644
--- a/litellm/proxy/auth/model_checks.py
+++ b/litellm/proxy/auth/model_checks.py
@@ -48,12 +48,16 @@ def get_provider_models(
def _get_models_from_access_groups(
model_access_groups: Dict[str, List[str]],
all_models: List[str],
+ include_model_access_groups: Optional[bool] = False,
) -> List[str]:
idx_to_remove = []
new_models = []
for idx, model in enumerate(all_models):
if model in model_access_groups:
- idx_to_remove.append(idx)
+ if (
+ not include_model_access_groups
+ ): # remove access group, unless requested - e.g. when creating a key and trying to see list of models
+ idx_to_remove.append(idx)
new_models.extend(model_access_groups[model])
for idx in sorted(idx_to_remove, reverse=True):
@@ -67,12 +71,14 @@ def get_key_models(
user_api_key_dict: UserAPIKeyAuth,
proxy_model_list: List[str],
model_access_groups: Dict[str, List[str]],
+ include_model_access_groups: Optional[bool] = False,
) -> List[str]:
"""
Returns:
- List of model name strings
- Empty list if no models set
- If model_access_groups is provided, only return models that are in the access groups
+ - If include_model_access_groups is True, it includes the 'keys' of the model_access_groups in the response - {"beta-models": ["gpt-4", "claude-v1"]} -> returns 'beta-models'
"""
all_models: List[str] = []
if len(user_api_key_dict.models) > 0:
@@ -94,6 +100,7 @@ def get_team_models(
team_models: List[str],
proxy_model_list: List[str],
model_access_groups: Dict[str, List[str]],
+ include_model_access_groups: Optional[bool] = False,
) -> List[str]:
"""
Returns:
@@ -110,7 +117,9 @@ def get_team_models(
all_models = proxy_model_list
all_models = _get_models_from_access_groups(
- model_access_groups=model_access_groups, all_models=all_models
+ model_access_groups=model_access_groups,
+ all_models=all_models,
+ include_model_access_groups=include_model_access_groups,
)
verbose_proxy_logger.debug("ALL TEAM MODELS - {}".format(len(all_models)))
@@ -125,6 +134,8 @@ def get_complete_model_list(
infer_model_from_keys: Optional[bool],
return_wildcard_routes: Optional[bool] = False,
llm_router: Optional[Router] = None,
+ model_access_groups: Dict[str, List[str]] = {},
+ include_model_access_groups: Optional[bool] = False,
) -> List[str]:
"""Logic for returning complete model list for a given key + team pair"""
@@ -141,6 +152,8 @@ def get_complete_model_list(
unique_models.update(team_models)
else:
unique_models.update(proxy_model_list)
+ if include_model_access_groups:
+ unique_models.update(model_access_groups.keys())
if user_model:
unique_models.add(user_model)
@@ -155,7 +168,9 @@ def get_complete_model_list(
llm_router=llm_router,
)
- return list(unique_models) + all_wildcard_models
+ complete_model_list = list(unique_models) + all_wildcard_models
+
+ return complete_model_list
def get_known_models_from_wildcard(
diff --git a/litellm/proxy/hooks/__init__.py b/litellm/proxy/hooks/__init__.py
index 9c78989cad4..12875139824 100644
--- a/litellm/proxy/hooks/__init__.py
+++ b/litellm/proxy/hooks/__init__.py
@@ -1,9 +1,11 @@
+import os
from typing import Literal, Union
from . import *
from .cache_control_check import _PROXY_CacheControlCheck
from .max_budget_limiter import _PROXY_MaxBudgetLimiter
from .parallel_request_limiter import _PROXY_MaxParallelRequestsHandler
+from .parallel_request_limiter_v2 import _PROXY_MaxParallelRequestsHandler_v2
### CHECK IF ENTERPRISE HOOKS ARE AVAILABLE ###
@@ -19,6 +21,11 @@ PROXY_HOOKS = {
"cache_control_check": _PROXY_CacheControlCheck,
}
+## FEATURE FLAG HOOKS ##
+if os.getenv("EXPERIMENTAL_MULTI_INSTANCE_RATE_LIMITING", "false").lower() == "true":
+ PROXY_HOOKS["max_parallel_requests"] = _PROXY_MaxParallelRequestsHandler_v2
+
+
### update PROXY_HOOKS with ENTERPRISE_PROXY_HOOKS ###
PROXY_HOOKS.update(ENTERPRISE_PROXY_HOOKS)
diff --git a/enterprise/enterprise_hooks/parallel_request_limiter_v2.py b/litellm/proxy/hooks/parallel_request_limiter_v2.py
similarity index 99%
rename from enterprise/enterprise_hooks/parallel_request_limiter_v2.py
rename to litellm/proxy/hooks/parallel_request_limiter_v2.py
index 3e778313719..2c7e024ea84 100644
--- a/enterprise/enterprise_hooks/parallel_request_limiter_v2.py
+++ b/litellm/proxy/hooks/parallel_request_limiter_v2.py
@@ -59,7 +59,7 @@ RateLimitGroups = Literal["request_count", "tpm", "rpm"]
RateLimitTypes = Literal["key", "model_per_key", "user", "customer", "team"]
-class _PROXY_MaxParallelRequestsHandler(BaseRoutingStrategy, CustomLogger):
+class _PROXY_MaxParallelRequestsHandler_v2(BaseRoutingStrategy, CustomLogger):
# Class variables or attributes
def __init__(self, internal_usage_cache: InternalUsageCache):
self.internal_usage_cache = internal_usage_cache
diff --git a/litellm/proxy/management_endpoints/model_management_endpoints.py b/litellm/proxy/management_endpoints/model_management_endpoints.py
index da00bd02afa..95fcd988a06 100644
--- a/litellm/proxy/management_endpoints/model_management_endpoints.py
+++ b/litellm/proxy/management_endpoints/model_management_endpoints.py
@@ -11,6 +11,7 @@ model/{model_id}/update - PATCH endpoint for model update.
#### MODEL MANAGEMENT ####
import asyncio
+import datetime
import json
import uuid
from typing import Dict, List, Literal, Optional, Union, cast
@@ -119,9 +120,12 @@ def update_db_model(
)
if "model_info" in merged_deployment_dict:
- prisma_compatible_model_dict["model_info"] = json.dumps(
- merged_deployment_dict["model_info"]
- )
+ model_info = merged_deployment_dict["model_info"]
+ for key, value in model_info.items():
+ if isinstance(value, datetime.datetime):
+ model_info[key] = value.isoformat()
+ prisma_compatible_model_dict["model_info"] = json.dumps(model_info)
+
return prisma_compatible_model_dict
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index 1e4c4adee06..1c457baf2f9 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -3390,6 +3390,7 @@ async def model_list(
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
return_wildcard_routes: Optional[bool] = False,
team_id: Optional[str] = None,
+ include_model_access_groups: Optional[bool] = False,
):
"""
Use `/model/info` - to get detailed model information, example - pricing, mode, etc.
@@ -3410,6 +3411,7 @@ async def model_list(
user_api_key_dict=user_api_key_dict,
proxy_model_list=proxy_model_list,
model_access_groups=model_access_groups,
+ include_model_access_groups=include_model_access_groups,
)
team_models: List[str] = user_api_key_dict.team_models
@@ -3429,6 +3431,7 @@ async def model_list(
team_models=team_models,
proxy_model_list=proxy_model_list,
model_access_groups=model_access_groups,
+ include_model_access_groups=include_model_access_groups,
)
all_models = get_complete_model_list(
@@ -3439,6 +3442,8 @@ async def model_list(
infer_model_from_keys=general_settings.get("infer_model_from_keys", False),
return_wildcard_routes=return_wildcard_routes,
llm_router=llm_router,
+ model_access_groups=model_access_groups,
+ include_model_access_groups=include_model_access_groups,
)
return dict(
diff --git a/tests/enterprise/enterprise_hooks/test_parallel_request_limiter_v2.py b/tests/litellm/proxy/hooks/test_parallel_request_limiter_v2.py
similarity index 99%
rename from tests/enterprise/enterprise_hooks/test_parallel_request_limiter_v2.py
rename to tests/litellm/proxy/hooks/test_parallel_request_limiter_v2.py
index 769b0822958..f0a3497a12d 100644
--- a/tests/enterprise/enterprise_hooks/test_parallel_request_limiter_v2.py
+++ b/tests/litellm/proxy/hooks/test_parallel_request_limiter_v2.py
@@ -10,12 +10,12 @@ import pytest
from fastapi import HTTPException
import litellm
-from enterprise.enterprise_hooks.parallel_request_limiter_v2 import (
- _PROXY_MaxParallelRequestsHandler,
-)
from litellm import Router
from litellm.caching.caching import DualCache
from litellm.proxy._types import UserAPIKeyAuth
+from litellm.proxy.hooks.parallel_request_limiter_v2 import (
+ _PROXY_MaxParallelRequestsHandler_v2 as _PROXY_MaxParallelRequestsHandler,
+)
from litellm.proxy.utils import InternalUsageCache, ProxyLogging, hash_token
diff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsx
index d484a81c13e..625a849b25e 100644
--- a/ui/litellm-dashboard/src/components/create_key_button.tsx
+++ b/ui/litellm-dashboard/src/components/create_key_button.tsx
@@ -104,7 +104,8 @@ export const fetchTeamModels = async (userID: string, userRole: string, accessTo
userID,
userRole,
true,
- teamID
+ teamID,
+ true
);
let available_model_names = model_available["data"].map(
(element: { id: string }) => element.id
diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/fetch_available_models_team_key.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/fetch_available_models_team_key.tsx
index d42399179c8..482b17ab33f 100644
--- a/ui/litellm-dashboard/src/components/key_team_helpers/fetch_available_models_team_key.tsx
+++ b/ui/litellm-dashboard/src/components/key_team_helpers/fetch_available_models_team_key.tsx
@@ -16,6 +16,8 @@ export const fetchAvailableModelsForTeamOrKey = async (
accessToken,
userID,
userRole,
+ true,
+ null,
true
);
diff --git a/ui/litellm-dashboard/src/components/model_info_view.tsx b/ui/litellm-dashboard/src/components/model_info_view.tsx
index f429b479ac6..a7d542e7d9a 100644
--- a/ui/litellm-dashboard/src/components/model_info_view.tsx
+++ b/ui/litellm-dashboard/src/components/model_info_view.tsx
@@ -142,13 +142,20 @@ export default function ModelInfoView({
} else {
delete updatedLitellmParams.cache_control_injection_points;
}
+
+ // Parse the model_info from the form values
+ let updatedModelInfo;
+ try {
+ updatedModelInfo = values.model_info ? JSON.parse(values.model_info) : modelData.model_info;
+ } catch (e) {
+ message.error("Invalid JSON in Model Info");
+ return;
+ }
const updateData = {
model_name: values.model_name,
litellm_params: updatedLitellmParams,
- model_info: {
- id: modelId,
- }
+ model_info: updatedModelInfo
};
await modelPatchUpdateCall(accessToken, updateData, modelId);
@@ -157,7 +164,8 @@ export default function ModelInfoView({
...localModelData,
model_name: values.model_name,
litellm_model_name: values.litellm_model_name,
- litellm_params: updatedLitellmParams
+ litellm_params: updatedLitellmParams,
+ model_info: updatedModelInfo
};
setLocalModelData(updatedModelData);
@@ -550,6 +558,24 @@ export default function ModelInfoView({
</div>
)}
+ <div>
+ <Text className="font-medium">Model Info</Text>
+ {isEditing ? (
+ <Form.Item name="model_info" className="mb-0">
+ <Input.TextArea
+ rows={4}
+ placeholder='{"gpt-4": 100, "claude-v1": 200}'
+ defaultValue={JSON.stringify(modelData.model_info, null, 2)}
+ />
+ </Form.Item>
+ ) : (
+ <div className="mt-1 p-2 bg-gray-50 rounded">
+ <pre className="bg-gray-100 p-2 rounded text-xs overflow-auto mt-1">
+ {JSON.stringify(localModelData.model_info, null, 2)}
+ </pre>
+ </div>
+ )}
+ </div>
<div>
<Text className="font-medium">Team ID</Text>
<div className="mt-1 p-2 bg-gray-50 rounded">
diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx
index 292acd7de76..86d63cfc17b 100644
--- a/ui/litellm-dashboard/src/components/networking.tsx
+++ b/ui/litellm-dashboard/src/components/networking.tsx
@@ -1869,7 +1869,8 @@ export const modelAvailableCall = async (
userID: String,
userRole: String,
return_wildcard_routes: boolean = false,
- teamID: String | null = null
+ teamID: String | null = null,
+ include_model_access_groups: boolean = false
) => {
/**
* Get all the models user has access to
@@ -1881,6 +1882,9 @@ export const modelAvailableCall = async (
if (return_wildcard_routes === true) {
params.append('return_wildcard_routes', 'True');
}
+ if (include_model_access_groups === true) {
+ params.append('include_model_access_groups', 'True');
+ }
if (teamID) {
params.append('team_id', teamID.toString());
}