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
feat(proxy_server.py): support retrieving models for a team, if user is a member - via `/models?team_id`
Krrish Dholakia26226d475f7a
diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.htmldeleted file mode 100644index e95db384ad1..00000000000--- a/litellm/proxy/_experimental/out/onboarding.html+++ /dev/null@@ -1 +0,0 @@-<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/ui/_next/static/chunks/webpack-75a5453f51d60261.js"/><script src="/ui/_next/static/chunks/fd9d1056-524b80e1a6b8bb06.js" async=""></script><script src="/ui/_next/static/chunks/117-883150efc583d711.js" async=""></script><script src="/ui/_next/static/chunks/main-app-4f7318ae681a6d94.js" async=""></script><title>LiteLLM Dashboard</title><meta name="description" content="LiteLLM Proxy Admin UI"/><link rel="icon" href="/ui/favicon.ico" type="image/x-icon" sizes="16x16"/><meta name="next-size-adjust"/><script src="/ui/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/ui/_next/static/chunks/webpack-75a5453f51d60261.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/ui/_next/static/media/a34f9d1faa5f3315-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/ui/_next/static/css/86f6cc749f6b8493.css\",\"style\"]\n3:HL[\"/ui/_next/static/css/c758d790167bcb96.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[12846,[],\"\"]\n6:I[19107,[],\"ClientPageRoot\"]\n7:I[12011,[\"665\",\"static/chunks/3014691f-0b72c78cfebbd712.js\",\"42\",\"static/chunks/42-1cbed529ecb084e0.js\",\"899\",\"static/chunks/899-9af4feaf6f21839c.js\",\"250\",\"static/chunks/250-72d2a43509e3fb1a.js\",\"461\",\"static/chunks/app/onboarding/page-e92e512268852411.js\"],\"default\",1]\n8:I[4707,[],\"\"]\n9:I[36423,[],\"\"]\nb:I[61060,[],\"\"]\nc:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L4\",null,{\"buildId\":\"F07EkIX5rHSWgmKLKDSY6\",\"assetPrefix\":\"/ui\",\"urlParts\":[\"\",\"onboarding\"],\"initialTree\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[\"$\",\"$L6\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$7\"}],null],null],null]},[null,[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"onboarding\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/ui/_next/static/css/86f6cc749f6b8493.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/ui/_next/static/css/c758d790167bcb96.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_cf7686\",\"children\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[null,\"$La\"],\"globalErrorComponent\":\"$b\",\"missingSlots\":\"$Wc\"}]\n"])</script><script>self.__next_f.push([1,"a:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"LiteLLM Dashboard\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"LiteLLM Proxy Admin UI\"}],[\"$\",\"link\",\"4\",{\"rel\":\"icon\",\"href\":\"/ui/favicon.ico\",\"type\":\"image/x-icon\",\"sizes\":\"16x16\"}],[\"$\",\"meta\",\"5\",{\"name\":\"next-size-adjust\"}]]\n5:null\n"])</script></body></html>\ No newline at end of filediff --git a/litellm/proxy/auth/model_checks.py b/litellm/proxy/auth/model_checks.pyindex 041d23bf0b3..a48ef6ae872 100644--- a/litellm/proxy/auth/model_checks.py+++ b/litellm/proxy/auth/model_checks.py@@ -85,7 +85,7 @@ def get_key_models(def get_team_models(- user_api_key_dict: UserAPIKeyAuth,+ team_models: List[str],proxy_model_list: List[str],model_access_groups: Dict[str, List[str]],) -> List[str]:@@ -96,10 +96,10 @@ def get_team_models(- If model_access_groups is provided, only return models that are in the access groups"""all_models = []- if len(user_api_key_dict.team_models) > 0:- all_models = user_api_key_dict.team_models+ if len(team_models) > 0:+ all_models = team_modelsif SpecialModelNames.all_team_models.value in all_models:- all_models = user_api_key_dict.team_models+ all_models = team_modelsif SpecialModelNames.all_proxy_models.value in all_models:all_models = proxy_model_listdiff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.pyindex 81f66421a79..52b2f432828 100644--- a/litellm/proxy/management_endpoints/team_endpoints.py+++ b/litellm/proxy/management_endpoints/team_endpoints.py@@ -1352,9 +1352,9 @@ async def team_info(else:_team_info = LiteLLM_TeamTable()- ## UNFURL 'all-proxy-models' into the team_info.models list ##- if llm_router is not None:- _team_info = _unfurl_all_proxy_models(_team_info, llm_router)+ # ## UNFURL 'all-proxy-models' into the team_info.models list ##+ # if llm_router is not None:+ # _team_info = _unfurl_all_proxy_models(_team_info, llm_router)response_object = TeamInfoResponseObject(team_id=team_id,team_info=_team_info,@@ -1615,11 +1615,6 @@ async def list_team()try:- # unfurl all-proxy-models- if llm_router is not None:- team = _unfurl_all_proxy_models(- LiteLLM_TeamTable(**team.model_dump()), llm_router- )returned_responses.append(TeamListResponseObject(**team.model_dump(),diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 250551b0193..a40522fd22a 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -122,7 +122,7 @@ from litellm.proxy.analytics_endpoints.analytics_endpoints import (router as analytics_router,)from litellm.proxy.anthropic_endpoints.endpoints import router as anthropic_router-from litellm.proxy.auth.auth_checks import log_db_metrics+from litellm.proxy.auth.auth_checks import get_team_object, log_db_metricsfrom litellm.proxy.auth.auth_utils import check_response_size_is_safefrom litellm.proxy.auth.handle_jwt import JWTHandlerfrom litellm.proxy.auth.litellm_license import LicenseCheck@@ -213,7 +213,10 @@ from litellm.proxy.management_endpoints.team_callback_endpoints import (router as team_callback_router,)from litellm.proxy.management_endpoints.team_endpoints import router as team_router-from litellm.proxy.management_endpoints.team_endpoints import update_team+from litellm.proxy.management_endpoints.team_endpoints import (+ update_team,+ validate_membership,+)from litellm.proxy.management_endpoints.ui_sso import (get_disabled_non_admin_personal_key_creation,)@@ -3380,13 +3383,14 @@ class ProxyStartupEvent: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,):"""Use `/model/info` - to get detailed model information, example - pricing, mode, etc.This is just for compatibility with openai projects like aider."""- global llm_model_list, general_settings, llm_router+ global llm_model_list, general_settings, llm_router, prisma_client, user_api_key_cache, proxy_logging_objall_models = []model_access_groups: Dict[str, List[str]] = defaultdict(list)## CHECK IF MODEL RESTRICTIONS ARE SET AT KEY/TEAM LEVEL ##@@ -3401,19 +3405,33 @@ async def model_list(model_access_groups=model_access_groups,)+ team_models: List[str] = user_api_key_dict.team_models++ if team_id:+ team_object = await get_team_object(+ team_id=team_id,+ prisma_client=prisma_client,+ user_api_key_cache=user_api_key_cache,+ proxy_logging_obj=proxy_logging_obj,+ )+ validate_membership(user_api_key_dict=user_api_key_dict, team_table=team_object)+ team_models = team_object.models+team_models = get_team_models(- user_api_key_dict=user_api_key_dict,+ team_models=team_models,proxy_model_list=proxy_model_list,model_access_groups=model_access_groups,)+all_models = get_complete_model_list(- key_models=key_models,+ key_models=key_models if not team_models else [],team_models=team_models,proxy_model_list=proxy_model_list,user_model=user_model,infer_model_from_keys=general_settings.get("infer_model_from_keys", False),return_wildcard_routes=return_wildcard_routes,)+return dict(data=[{@@ -6117,7 +6135,7 @@ async def model_info_v1( # noqa: PLR0915model_access_groups=model_access_groups,)team_models = get_team_models(- user_api_key_dict=user_api_key_dict,+ team_models=user_api_key_dict.team_models,proxy_model_list=proxy_model_list,model_access_groups=model_access_groups,)@@ -6344,7 +6362,7 @@ async def model_group_info(model_access_groups=model_access_groups,)team_models = get_team_models(- user_api_key_dict=user_api_key_dict,+ team_models=user_api_key_dict.team_models,proxy_model_list=proxy_model_list,model_access_groups=model_access_groups,)