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]

feat(teams): per-member model scope + team default_team_member_models (#24950)

ishaan-berri414d3966bfe2
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260401000000_add_team_member_model_scope/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260401000000_add_team_member_model_scope/migration.sql
new file mode 100644
index 00000000000..d34482b3390
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260401000000_add_team_member_model_scope/migration.sql
@@ -0,0 +1,9 @@
+-- Add per-member model scope to LiteLLM_BudgetTable
+-- allowed_models: empty array = inherit team models; non-empty = enforce member-level restriction
+ALTER TABLE "LiteLLM_BudgetTable"
+ ADD COLUMN IF NOT EXISTS "allowed_models" TEXT[] DEFAULT ARRAY[]::TEXT[];
+
+-- Add default_team_member_models to LiteLLM_TeamTable
+-- Seeds allowed_models for newly added team members; empty = no per-member restriction
+ALTER TABLE "LiteLLM_TeamTable"
+ ADD COLUMN IF NOT EXISTS "default_team_member_models" TEXT[] DEFAULT ARRAY[]::TEXT[];
diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
index fce95465b55..03760695f30 100644
--- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
+++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
@@ -17,8 +17,9 @@ model LiteLLM_BudgetTable {
tpm_limit BigInt?
rpm_limit BigInt?
model_max_budget Json?
- budget_duration String?
+ budget_duration String?
budget_reset_at DateTime?
+ allowed_models String[] @default([]) // per-member model scope; empty = inherit team models
created_at DateTime @default(now()) @map("created_at")
created_by String
updated_at DateTime @default(now()) @updatedAt @map("updated_at")
@@ -140,6 +141,7 @@ model LiteLLM_TeamTable {
team_member_permissions String[] @default([])
access_group_ids String[] @default([])
policies String[] @default([])
+ default_team_member_models String[] @default([]) // default allowed_models for newly added team members; empty = no per-member restriction
model_id Int? @unique // id for LiteLLM_ModelTable -> stores team-level model aliases
allow_team_guardrail_config Boolean @default(false) // if true, team admin can configure guardrails for this team
litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
diff --git a/litellm/llms/bedrock/common_utils.py b/litellm/llms/bedrock/common_utils.py
index 9666aa68c99..a7cb6ed9f15 100644
--- a/litellm/llms/bedrock/common_utils.py
+++ b/litellm/llms/bedrock/common_utils.py
@@ -432,12 +432,16 @@ def strip_bedrock_routing_prefix(model: str) -> str:
def strip_bedrock_throughput_suffix(model: str) -> str:
- """Strip throughput tier suffixes from Bedrock model names."""
+ """Strip throughput tier suffixes and context window suffixes from Bedrock model names."""
import re
# Pattern matches model:version:throughput where throughput is like 51k, 18k, etc.
# Keep the model:version part, strip the :throughput suffix
- return re.sub(r"(:\d+):\d+k$", r"\1", model)
+ model = re.sub(r"(:\d+):\d+k$", r"\1", model)
+ # Strip context window suffixes like [1m], [200k], etc.
+ # e.g. "us.anthropic.claude-opus-4-6-v1[1m]" -> "us.anthropic.claude-opus-4-6-v1"
+ model = re.sub(r"\[\w+\]$", "", model)
+ return model
def get_bedrock_base_model(model: str) -> str:
@@ -1062,9 +1066,11 @@ class CommonBatchFilesUtils:
return (
dict(prepped.headers),
- request_data.encode("utf-8")
- if isinstance(request_data, str)
- else request_data,
+ (
+ request_data.encode("utf-8")
+ if isinstance(request_data, str)
+ else request_data
+ ),
)
def generate_unique_job_name(self, model: str, prefix: str = "litellm") -> str:
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index 441b3b836a1..452ba7f7995 100644
--- a/litellm/proxy/_types.py
+++ b/litellm/proxy/_types.py
@@ -1649,6 +1649,9 @@ class TeamBase(LiteLLMPydanticObjectBase):
blocked: bool = False
router_settings: Optional[dict] = None
access_group_ids: Optional[List[str]] = None
+ default_team_member_models: Optional[List[str]] = (
+ None # default allowed_models seeded onto new team members
+ )
class NewTeamRequest(TeamBase):
@@ -1742,6 +1745,9 @@ class UpdateTeamRequest(LiteLLMPydanticObjectBase):
enforced_file_expires_after: Optional[dict] = None
router_settings: Optional[dict] = None
access_group_ids: Optional[List[str]] = None
+ default_team_member_models: Optional[List[str]] = (
+ None # default allowed_models seeded onto new team members
+ )
class ResetTeamBudgetRequest(LiteLLMPydanticObjectBase):
@@ -1943,6 +1949,9 @@ class LiteLLM_BudgetTable(LiteLLMPydanticObjectBase):
rpm_limit: Optional[int] = None
model_max_budget: Optional[dict] = None
budget_duration: Optional[str] = None
+ allowed_models: Optional[List[str]] = (
+ None # per-member model scope; empty = inherit team models
+ )
model_config = ConfigDict(protected_namespaces=())
@@ -3735,6 +3744,10 @@ class TeamMemberAddRequest(MemberAddRequest):
default=None,
description="Maximum budget allocated to this user within the team. If not set, user has unlimited budget within team limits",
)
+ allowed_models: Optional[List[str]] = Field(
+ default=None,
+ description="List of models this team member can access. If not set, inherits the team's default_team_member_models or all team models.",
+ )
class TeamMemberDeleteRequest(MemberDeleteRequest):
@@ -3750,6 +3763,10 @@ class TeamMemberUpdateRequest(TeamMemberDeleteRequest):
rpm_limit: Optional[int] = Field(
default=None, description="Requests per minute limit for this team member"
)
+ allowed_models: Optional[List[str]] = Field(
+ default=None,
+ description="List of models this team member can access. Pass an empty list to remove per-member model restrictions.",
+ )
class TeamMemberUpdateResponse(MemberUpdateResponse):
@@ -3757,6 +3774,7 @@ class TeamMemberUpdateResponse(MemberUpdateResponse):
max_budget_in_team: Optional[float] = None
tpm_limit: Optional[int] = None
rpm_limit: Optional[int] = None
+ allowed_models: Optional[List[str]] = None
class TeamModelAddRequest(BaseModel):
diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py
index 68bde8434a6..bf0de3d3ca8 100644
--- a/litellm/proxy/auth/auth_checks.py
+++ b/litellm/proxy/auth/auth_checks.py
@@ -8,6 +8,7 @@ Run checks for:
2. If user is in budget
3. If end_user ('user' passed to /chat/completions, /embeddings endpoint) is in budget
"""
+
import asyncio
import re
import time
@@ -456,9 +457,9 @@ async def common_checks( # noqa: PLR0915
model=_model,
team_object=team_object,
llm_router=llm_router,
- team_model_aliases=valid_token.team_model_aliases
- if valid_token
- else None,
+ team_model_aliases=(
+ valid_token.team_model_aliases if valid_token else None
+ ),
):
raise ProxyException(
message=f"Team not allowed to access model. Team={team_object.team_id}, Model={_model}. Allowed team models = {team_object.models}",
@@ -467,6 +468,21 @@ async def common_checks( # noqa: PLR0915
code=status.HTTP_401_UNAUTHORIZED,
)
+ # 2.2. If team member has per-member model scope, enforce it
+ if _model and team_object and valid_token and valid_token.user_id:
+ with tracer.trace(
+ "litellm.proxy.auth.common_checks.check_team_member_model_access"
+ ):
+ await _check_team_member_model_access(
+ model=_model,
+ team_object=team_object,
+ valid_token=valid_token,
+ llm_router=llm_router,
+ prisma_client=prisma_client,
+ user_api_key_cache=user_api_key_cache,
+ proxy_logging_obj=proxy_logging_obj,
+ )
+
# Require trace id for agent keys when agent has require_trace_id_on_calls_by_agent
if valid_token is not None and valid_token.agent_id:
from litellm.proxy.agent_endpoints.agent_registry import global_agent_registry
@@ -3108,6 +3124,58 @@ async def _check_team_member_budget(
)
+async def _check_team_member_model_access(
+ model: Union[str, List[str]],
+ team_object: LiteLLM_TeamTable,
+ valid_token: UserAPIKeyAuth,
+ llm_router: Optional[Router],
+ prisma_client: Optional["PrismaClient"],
+ user_api_key_cache: DualCache,
+ proxy_logging_obj: ProxyLogging,
+) -> None:
+ """
+ Check if a team member's per-member model scope allows access to the requested model.
+
+ Only enforced when the member's budget table has a non-empty allowed_models list.
+ If allowed_models is empty or absent, the team-level models list applies (no extra restriction).
+ """
+ if valid_token.user_id is None or team_object.team_id is None:
+ return
+
+ team_membership = await get_team_membership(
+ user_id=valid_token.user_id,
+ team_id=team_object.team_id,
+ prisma_client=prisma_client,
+ user_api_key_cache=user_api_key_cache,
+ proxy_logging_obj=proxy_logging_obj,
+ )
+
+ if (
+ team_membership is None
+ or team_membership.litellm_budget_table is None
+ or not team_membership.litellm_budget_table.allowed_models
+ ):
+ return # no per-member restriction — inherit team-level check
+
+ member_allowed_models: List[str] = (
+ team_membership.litellm_budget_table.allowed_models
+ )
+ try:
+ _can_object_call_model(
+ model=model,
+ llm_router=llm_router,
+ models=member_allowed_models,
+ object_type="team",
+ )
+ except ProxyException:
+ raise ProxyException(
+ message=f"Team member not allowed to access model. User={valid_token.user_id}, Team={team_object.team_id}, Model={model}. Allowed member models = {member_allowed_models}",
+ type=ProxyErrorTypes.team_model_access_denied,
+ param="model",
+ code=status.HTTP_401_UNAUTHORIZED,
+ )
+
+
async def _team_max_budget_check(
team_object: Optional[LiteLLM_TeamTable],
valid_token: Optional[UserAPIKeyAuth],
diff --git a/litellm/proxy/management_endpoints/common_utils.py b/litellm/proxy/management_endpoints/common_utils.py
index efc42d3355c..07286b4fa80 100644
--- a/litellm/proxy/management_endpoints/common_utils.py
+++ b/litellm/proxy/management_endpoints/common_utils.py
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Any, Dict, Optional, Union
+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
from litellm._logging import verbose_proxy_logger
from litellm.caching import DualCache
@@ -354,6 +354,7 @@ async def _upsert_budget_and_membership(
user_api_key_dict: UserAPIKeyAuth,
tpm_limit: Optional[int] = None,
rpm_limit: Optional[int] = None,
+ allowed_models: Optional[List[str]] = None,
):
"""
Helper function to Create/Update or Delete the budget within the team membership
@@ -366,11 +367,17 @@ async def _upsert_budget_and_membership(
user_api_key_dict: User API Key dictionary containing user information
tpm_limit: Tokens per minute limit for the team member
rpm_limit: Requests per minute limit for the team member
+ allowed_models: Per-member model scope. None = don't change. [] = remove restrictions. Non-empty list = enforce.
- If max_budget, tpm_limit, and rpm_limit are all None, the user's budget is removed from the team membership.
+ If max_budget, tpm_limit, rpm_limit, and allowed_models are all None, the user's budget is removed from the team membership.
If any of these values exist, a budget is updated or created and linked to the team membership.
"""
- if max_budget is None and tpm_limit is None and rpm_limit is None:
+ if (
+ max_budget is None
+ and tpm_limit is None
+ and rpm_limit is None
+ and allowed_models is None
+ ):
# disconnect the budget since all limits are None
await tx.litellm_teammembership.update(
where={"user_id_team_id": {"user_id": user_id, "team_id": team_id}},
@@ -378,7 +385,27 @@ async def _upsert_budget_and_membership(
)
return
- # create a new budget
+ if existing_budget_id is not None:
+ # Update the existing budget in-place to preserve fields not being changed.
+ # Only write fields that the caller explicitly provided (non-None).
+ update_data: Dict[str, Any] = {
+ "updated_by": user_api_key_dict.user_id or "",
+ }
+ if max_budget is not None:
+ update_data["max_budget"] = max_budget
+ if tpm_limit is not None:
+ update_data["tpm_limit"] = tpm_limit
+ if rpm_limit is not None:
+ update_data["rpm_limit"] = rpm_limit
+ if allowed_models is not None:
+ update_data["allowed_models"] = allowed_models
+ await tx.litellm_budgettable.update(
+ where={"budget_id": existing_budget_id},
+ data=update_data,
+ )
+ return
+
+ # No existing budget — create a new one and link it to the membership.
create_data: Dict[str, Any] = {
"created_by": user_api_key_dict.user_id or "",
"updated_by": user_api_key_dict.user_id or "",
@@ -389,12 +416,13 @@ async def _upsert_budget_and_membership(
create_data["tpm_limit"] = tpm_limit
if rpm_limit is not None:
create_data["rpm_limit"] = rpm_limit
+ if allowed_models is not None:
+ create_data["allowed_models"] = allowed_models
new_budget = await tx.litellm_budgettable.create(
data=create_data,
include={"team_membership": True},
)
- # upsert the team membership with the new/updated budget
await tx.litellm_teammembership.upsert(
where={
"user_id_team_id": {
diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py
index e1534573789..c980fcb82f8 100644
--- a/litellm/proxy/management_endpoints/team_endpoints.py
+++ b/litellm/proxy/management_endpoints/team_endpoints.py
@@ -1545,12 +1545,12 @@ async def update_team( # noqa: PLR0915
updated_kv["router_settings"] = safe_dumps(updated_kv["router_settings"])
updated_kv = prisma_client.jsonify_team_object(db_data=updated_kv)
- team_row: Optional[
- LiteLLM_TeamTable
- ] = await prisma_client.db.litellm_teamtable.update(
- where={"team_id": data.team_id},
- data=updated_kv,
- include={"litellm_model_table": True}, # type: ignore
+ team_row: Optional[LiteLLM_TeamTable] = (
+ await prisma_client.db.litellm_teamtable.update(
+ where={"team_id": data.team_id},
+ data=updated_kv,
+ include={"litellm_model_table": True}, # type: ignore
+ )
)
if team_row is None or team_row.team_id is None:
@@ -1764,6 +1764,11 @@ async def _process_team_members(
else None
)
+ # Resolve allowed_models: explicit request value, or fall back to team's default_team_member_models
+ member_allowed_models = data.allowed_models
+ if member_allowed_models is None and complete_team_data.default_team_member_models:
+ member_allowed_models = complete_team_data.default_team_member_models
+
if isinstance(data.member, Member):
try:
updated_user, updated_tm = await add_new_member(
@@ -1774,6 +1779,7 @@ async def _process_team_members(
litellm_proxy_admin_name=litellm_proxy_admin_name,
team_id=data.team_id,
default_team_budget_id=default_team_budget_id,
+ allowed_models=member_allowed_models,
)
except Exception as e:
raise HTTPException(
@@ -1798,6 +1804,7 @@ async def _process_team_members(
litellm_proxy_admin_name=litellm_proxy_admin_name,
team_id=data.team_id,
default_team_budget_id=default_team_budget_id,
+ allowed_models=member_allowed_models,
)
except Exception as e:
raise HTTPException(
@@ -2297,13 +2304,13 @@ async def team_member_delete(
)
# Fetch keys before deletion to persist them
- keys_to_delete: List[
- LiteLLM_VerificationToken
- ] = await prisma_client.db.litellm_verificationtoken.find_many(
- where={
- "user_id": {"in": list(user_ids_to_delete)},
- "team_id": data.team_id,
- }
+ keys_to_delete: List[LiteLLM_VerificationToken] = (
+ await prisma_client.db.litellm_verificationtoken.find_many(
+ where={
+ "user_id": {"in": list(user_ids_to_delete)},
+ "team_id": data.team_id,
+ }
+ )
)
if keys_to_delete:
@@ -2435,6 +2442,7 @@ async def team_member_update(
user_api_key_dict=user_api_key_dict,
tpm_limit=data.tpm_limit,
rpm_limit=data.rpm_limit,
+ allowed_models=data.allowed_models,
)
### update team member role
@@ -2467,6 +2475,7 @@ async def team_member_update(
max_budget_in_team=data.max_budget_in_team,
tpm_limit=data.tpm_limit,
rpm_limit=data.rpm_limit,
+ allowed_models=data.allowed_models,
)
@@ -2687,10 +2696,10 @@ async def delete_team(
team_rows: List[LiteLLM_TeamTable] = []
for team_id in data.team_ids:
try:
- team_row_base: Optional[
- BaseModel
- ] = await prisma_client.db.litellm_teamtable.find_unique(
- where={"team_id": team_id}
+ team_row_base: Optional[BaseModel] = (
+ await prisma_client.db.litellm_teamtable.find_unique(
+ where={"team_id": team_id}
+ )
)
if team_row_base is None:
raise Exception
@@ -2749,10 +2758,10 @@ async def delete_team(
_persist_deleted_verification_tokens,
)
- keys_to_delete: List[
- LiteLLM_VerificationToken
- ] = await prisma_client.db.litellm_verificationtoken.find_many(
- where={"team_id": {"in": data.team_ids}}
+ keys_to_delete: List[LiteLLM_VerificationToken] = (
+ await prisma_client.db.litellm_verificationtoken.find_many(
+ where={"team_id": {"in": data.team_ids}}
+ )
)
if keys_to_delete:
@@ -2991,11 +3000,11 @@ async def team_info(
)
try:
- team_info: Optional[
- BaseModel
- ] = await prisma_client.db.litellm_teamtable.find_unique(
- where={"team_id": team_id},
- include={"object_permission": True},
+ team_info: Optional[BaseModel] = (
+ await prisma_client.db.litellm_teamtable.find_unique(
+ where={"team_id": team_id},
+ include={"object_permission": True},
+ )
)
if team_info is None:
raise Exception
@@ -3316,7 +3325,7 @@ async def _build_team_list_where_conditions(
user_object_correct_type = await get_user_object(
user_id=user_id,
prisma_client=prisma_client,
- user_api_key_cache=user_api_key_cache,
+ user_api_key_cache=user_api_key_cache, # type: ignore[arg-type]
user_id_upsert=False,
proxy_logging_obj=proxy_logging_obj,
)
@@ -3835,9 +3844,7 @@ async def list_team(
except Exception as e:
team_exception = """Invalid team object for team_id: {}. team_object={}.
Error: {}
- """.format(
- team.team_id, team.model_dump(), str(e)
- )
+ """.format(team.team_id, team.model_dump(), str(e))
verbose_proxy_logger.exception(team_exception)
continue
# Sort the responses by team_alias
diff --git a/litellm/proxy/management_helpers/utils.py b/litellm/proxy/management_helpers/utils.py
index 7d485fdebde..3e42d392077 100644
--- a/litellm/proxy/management_helpers/utils.py
+++ b/litellm/proxy/management_helpers/utils.py
@@ -2,7 +2,7 @@
## Helper utils for the management endpoints (keys/users/teams)
from datetime import datetime
from functools import wraps
-from typing import Optional, Tuple
+from typing import List, Optional, Tuple
from fastapi import HTTPException, Request
@@ -148,6 +148,7 @@ async def add_new_member(
user_api_key_dict: UserAPIKeyAuth,
litellm_proxy_admin_name: str,
default_team_budget_id: Optional[str] = None,
+ allowed_models: Optional[List[str]] = None,
) -> Tuple[LiteLLM_UserTable, Optional[LiteLLM_TeamMembership]]:
"""
Add a new member to a team
@@ -206,17 +207,18 @@ async def add_new_member(
},
)
- # Check if trying to set a budget for team member
-
- if max_budget_in_team is not None:
+ # Check if trying to set a budget or model scope for team member
+ if max_budget_in_team is not None or allowed_models is not None:
# create a new budget item for this member
- response = await prisma_client.db.litellm_budgettable.create(
- data={
- "max_budget": max_budget_in_team,
- "created_by": user_api_key_dict.user_id or litellm_proxy_admin_name,
- "updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name,
- }
- )
+ budget_data: dict = {
+ "created_by": user_api_key_dict.user_id or litellm_proxy_admin_name,
+ "updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name,
+ }
+ if max_budget_in_team is not None:
+ budget_data["max_budget"] = max_budget_in_team
+ if allowed_models is not None:
+ budget_data["allowed_models"] = allowed_models
+ response = await prisma_client.db.litellm_budgettable.create(data=budget_data)
_budget_id = response.budget_id
else:
diff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prisma
index fce95465b55..03760695f30 100644
--- a/litellm/proxy/schema.prisma
+++ b/litellm/proxy/schema.prisma
@@ -17,8 +17,9 @@ model LiteLLM_BudgetTable {
tpm_limit BigInt?
rpm_limit BigInt?
model_max_budget Json?
- budget_duration String?
+ budget_duration String?
budget_reset_at DateTime?
+ allowed_models String[] @default([]) // per-member model scope; empty = inherit team models
created_at DateTime @default(now()) @map("created_at")
created_by String
updated_at DateTime @default(now()) @updatedAt @map("updated_at")
@@ -140,6 +141,7 @@ model LiteLLM_TeamTable {
team_member_permissions String[] @default([])
access_group_ids String[] @default([])
policies String[] @default([])
+ default_team_member_models String[] @default([]) // default allowed_models for newly added team members; empty = no per-member restriction
model_id Int? @unique // id for LiteLLM_ModelTable -> stores team-level model aliases
allow_team_guardrail_config Boolean @default(false) // if true, team admin can configure guardrails for this team
litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
diff --git a/schema.prisma b/schema.prisma
index fce95465b55..03760695f30 100644
--- a/schema.prisma
+++ b/schema.prisma
@@ -17,8 +17,9 @@ model LiteLLM_BudgetTable {
tpm_limit BigInt?
rpm_limit BigInt?
model_max_budget Json?
- budget_duration String?
+ budget_duration String?
budget_reset_at DateTime?
+ allowed_models String[] @default([]) // per-member model scope; empty = inherit team models
created_at DateTime @default(now()) @map("created_at")
created_by String
updated_at DateTime @default(now()) @updatedAt @map("updated_at")
@@ -140,6 +141,7 @@ model LiteLLM_TeamTable {
team_member_permissions String[] @default([])
access_group_ids String[] @default([])
policies String[] @default([])
+ default_team_member_models String[] @default([]) // default allowed_models for newly added team members; empty = no per-member restriction
model_id Int? @unique // id for LiteLLM_ModelTable -> stores team-level model aliases
allow_team_guardrail_config Boolean @default(false) // if true, team admin can configure guardrails for this team
litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
diff --git a/tests/test_litellm/llms/bedrock/test_bedrock_common_utils.py b/tests/test_litellm/llms/bedrock/test_bedrock_common_utils.py
index 5ce291aa165..a4e621b0bbd 100644
--- a/tests/test_litellm/llms/bedrock/test_bedrock_common_utils.py
+++ b/tests/test_litellm/llms/bedrock/test_bedrock_common_utils.py
@@ -29,25 +29,30 @@ def test_govcloud_cross_region_inference_prefix():
Test that GovCloud models with cross-region inference prefix (us-gov.) are parsed correctly
"""
bedrock_model_info = BedrockModelInfo
-
+
# Test us-gov prefix is stripped correctly for Claude models
base_model = bedrock_model_info.get_base_model(
model="bedrock/us-gov.anthropic.claude-haiku-4-5-20251001-v1:0"
)
+<<<<<<< worktree-rustling-wishing-kite
+ assert base_model == "anthropic.claude-3-5-sonnet-20240620-v1:0"
+
+=======
assert base_model == "anthropic.claude-haiku-4-5-20251001-v1:0"
+>>>>>>> main
# Test us-gov prefix is stripped correctly for different Claude versions
base_model = bedrock_model_info.get_base_model(
model="bedrock/us-gov.anthropic.claude-sonnet-4-5-20250929-v1:0"
)
assert base_model == "anthropic.claude-sonnet-4-5-20250929-v1:0"
-
+
# Test us-gov prefix is stripped correctly for Haiku models
base_model = bedrock_model_info.get_base_model(
model="bedrock/us-gov.anthropic.claude-3-haiku-20240307-v1:0"
)
assert base_model == "anthropic.claude-3-haiku-20240307-v1:0"
-
+
# Test us-gov prefix is stripped correctly for Meta models
base_model = bedrock_model_info.get_base_model(
model="bedrock/us-gov.meta.llama3-8b-instruct-v1:0"
@@ -55,3 +60,35 @@ def test_govcloud_cross_region_inference_prefix():
assert base_model == "meta.llama3-8b-instruct-v1:0"
+def test_context_window_suffix_stripped_for_cost_lookup():
+ """
+ Test that [1m], [200k] etc. context window suffixes are stripped from
+ Bedrock model names before cost lookup.
+
+ Models configured like `bedrock/us.anthropic.claude-opus-4-6-v1[1m]`
+ should resolve to the base model name so pricing can be found.
+ """
+ from litellm.llms.bedrock.common_utils import get_bedrock_base_model
+
+ assert (
+ get_bedrock_base_model("us.anthropic.claude-opus-4-6-v1[1m]")
+ == "anthropic.claude-opus-4-6-v1"
+ )
+ assert (
+ get_bedrock_base_model("us.anthropic.claude-sonnet-4-6[1m]")
+ == "anthropic.claude-sonnet-4-6"
+ )
+ assert (
+ get_bedrock_base_model("global.anthropic.claude-opus-4-5-20251101-v1:0[1m]")
+ == "anthropic.claude-opus-4-5-20251101-v1:0"
+ )
+ # Ensure models without suffix are unaffected
+ assert (
+ get_bedrock_base_model("us.anthropic.claude-opus-4-6-v1")
+ == "anthropic.claude-opus-4-6-v1"
+ )
+ # Ensure :51k throughput suffix still works
+ assert (
+ get_bedrock_base_model("anthropic.claude-3-5-sonnet-20241022-v2:0:51k")
+ == "anthropic.claude-3-5-sonnet-20241022-v2:0"
+ )
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/teams/components/modals/CreateTeamModal.tsx b/ui/litellm-dashboard/src/app/(dashboard)/teams/components/modals/CreateTeamModal.tsx
index 0aa42b69a04..b4f99f5ca8b 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/teams/components/modals/CreateTeamModal.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/teams/components/modals/CreateTeamModal.tsx
@@ -391,6 +391,80 @@ const CreateTeamModal = ({
</Select2>
</Form.Item>
+ <Accordion className="mt-8 mb-8">
+ <AccordionHeader>
+ <b>Team Member Settings</b>
+ </AccordionHeader>
+ <AccordionBody>
+ <Text className="text-xs text-gray-500 mb-4">
+ Optional defaults applied when members join this team. All fields can be overridden per member.
+ </Text>
+ <Form.Item
+ noStyle
+ shouldUpdate={(prev, cur) => prev.models !== cur.models}
+ >
+ {({ getFieldValue }) => {
+ const teamModels: string[] = getFieldValue("models") || [];
+ const opts = teamModels.length > 0 ? teamModels : modelsToPick;
+ return (
+ <Form.Item
+ label={
+ <span>
+ Default Model Access{" "}
+ <Tooltip title="Optional. If set, new members can only access these models by default. Must be a subset of the team's models. Leave empty to give all members access to all team models.">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ }
+ name="default_team_member_models"
+ >
+ <Select2
+ mode="multiple"
+ placeholder="Leave empty — all team models accessible to every member"
+ style={{ width: "100%" }}
+ >
+ {opts.map((m) => (
+ <Select2.Option key={m} value={m}>
+ {getModelDisplayName(m)}
+ </Select2.Option>
+ ))}
+ </Select2>
+ </Form.Item>
+ );
+ }}
+ </Form.Item>
+ <Form.Item
+ label="Default Member Budget (USD)"
+ name="team_member_budget"
+ normalize={(value) => (value ? Number(value) : undefined)}
+ tooltip="Default spend budget for each member in this team."
+ >
+ <NumericalInput step={0.01} precision={2} width={200} />
+ </Form.Item>
+ <Form.Item
+ label="Default Key Duration (eg: 1d, 1mo)"
+ name="team_member_key_duration"
+ tooltip="Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)"
+ >
+ <TextInput placeholder="e.g., 30d" />
+ </Form.Item>
+ <Form.Item
+ label="Default RPM Limit"
+ name="team_member_rpm_limit"
+ tooltip="Default requests per minute limit for each member. Can be overridden per member."
+ >
+ <NumericalInput step={1} width={400} />
+ </Form.Item>
+ <Form.Item
+ label="Default TPM Limit"
+ name="team_member_tpm_limit"
+ tooltip="Default tokens per minute limit for each member. Can be overridden per member."
+ >
+ <NumericalInput step={1} width={400} />
+ </Form.Item>
+ </AccordionBody>
+ </Accordion>
+
<Form.Item label="Max Budget (USD)" name="max_budget">
<NumericalInput step={0.01} precision={2} width={200} />
</Form.Item>
@@ -409,7 +483,7 @@ const CreateTeamModal = ({
</Form.Item>
<Accordion
- className="mt-20 mb-8"
+ className="mt-8 mb-8"
onClick={() => {
if (!mcpAccessGroupsLoaded) {
fetchMcpAccessGroups();
@@ -432,35 +506,6 @@ const CreateTeamModal = ({
}}
/>
</Form.Item>
- <Form.Item
- label="Team Member Budget (USD)"
- name="team_member_budget"
- normalize={(value) => (value ? Number(value) : undefined)}
- tooltip="This is the individual budget for a user in the team."
- >
- <NumericalInput step={0.01} precision={2} width={200} />
- </Form.Item>
- <Form.Item
- label="Team Member Key Duration (eg: 1d, 1mo)"
- name="team_member_key_duration"
- tooltip="Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)"
- >
- <TextInput placeholder="e.g., 30d" />
- </Form.Item>
- <Form.Item
- label="Team Member RPM Limit"
- name="team_member_rpm_limit"
- tooltip="The RPM (Requests Per Minute) limit for individual team members"
- >
- <NumericalInput step={1} width={400} />
- </Form.Item>
- <Form.Item
- label="Team Member TPM Limit"
- name="team_member_tpm_limit"
- tooltip="The TPM (Tokens Per Minute) limit for individual team members"
- >
- <NumericalInput step={1} width={400} />
- </Form.Item>
<Form.Item
label="Metadata"
name="metadata"
diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx
index 28f8d308de7..3e313a43469 100644
--- a/ui/litellm-dashboard/src/components/networking.tsx
+++ b/ui/litellm-dashboard/src/components/networking.tsx
@@ -3759,6 +3759,7 @@ export interface Member {
max_budget_in_team?: number | null;
tpm_limit?: number | null;
rpm_limit?: number | null;
+ allowed_models?: string[] | null;
}
export const teamMemberAddCall = async (accessToken: string, teamId: string, formValues: Member) => {
@@ -3898,6 +3899,9 @@ export const teamMemberUpdateCall = async (
if (formValues.rpm_limit !== undefined && formValues.rpm_limit !== null) {
requestBody.rpm_limit = formValues.rpm_limit;
}
+ if (formValues.allowed_models !== undefined) {
+ requestBody.allowed_models = formValues.allowed_models;
+ }
console.log("Final request body:", requestBody);
diff --git a/ui/litellm-dashboard/src/components/team/EditMembership.tsx b/ui/litellm-dashboard/src/components/team/EditMembership.tsx
index e6d9ccad60b..cc655ba52b9 100644
--- a/ui/litellm-dashboard/src/components/team/EditMembership.tsx
+++ b/ui/litellm-dashboard/src/components/team/EditMembership.tsx
@@ -21,7 +21,7 @@ interface ModalConfig {
additionalFields?: Array<{
name: string;
label: string | React.ReactNode;
- type: "input" | "select" | "numerical";
+ type: "input" | "select" | "numerical" | "multi-select";
options?: Array<{ label: string; value: string }>;
rules?: any[];
step?: number;
@@ -65,6 +65,8 @@ const MemberModal = <T extends BaseMember>({
max_budget_in_team: (initialData as any).max_budget_in_team || null,
tpm_limit: (initialData as any).tpm_limit || null,
rpm_limit: (initialData as any).rpm_limit || null,
+ // Keep array values for multi-select fields
+ allowed_models: (initialData as any).allowed_models || [],
};
console.log("Setting form values:", formValues);
form.setFieldsValue(formValues);
@@ -115,7 +117,7 @@ const MemberModal = <T extends BaseMember>({
const renderField = (field: {
name: string;
label: string | React.ReactNode;
- type: "input" | "select" | "numerical";
+ type: "input" | "select" | "numerical" | "multi-select";
options?: Array<{ label: string; value: string }>;
rules?: any[];
step?: number;
@@ -144,6 +146,15 @@ const MemberModal = <T extends BaseMember>({
))}
</Select>
);
+ case "multi-select":
+ return (
+ <Select
+ mode="multiple"
+ placeholder={field.placeholder || "Select options"}
+ options={field.options}
+ allowClear
+ />
+ );
default:
return null;
}
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
index 6308be65860..45d157a946c 100644
--- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
@@ -66,6 +66,7 @@ export interface TeamMembership {
rpm_limit: number | null;
model_max_budget: Record<string, number> | null;
budget_duration: string | null;
+ allowed_models?: string[] | null;
};
}
@@ -95,9 +96,13 @@ export interface TeamData {
} | null;
created_at: string;
access_group_ids?: string[];
+<<<<<<< worktree-rustling-wishing-kite
+ default_team_member_models?: string[];
+=======
access_group_models?: string[];
access_group_mcp_server_ids?: string[];
access_group_agent_ids?: string[];
+>>>>>>> main
guardrails?: string[];
policies?: string[];
object_permission?: {
@@ -381,6 +386,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
max_budget_in_team: values.max_budget_in_team,
tpm_limit: values.tpm_limit,
rpm_limit: values.rpm_limit,
+ allowed_models: values.allowed_models,
};
MessageManager.destroy(); // Remove all existing toasts
@@ -588,6 +594,11 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
updateData.access_group_ids = values.access_group_ids;
}
+ // Pass default_team_member_models to the update request
+ if (values.default_team_member_models !== undefined) {
+ updateData.default_team_member_models = values.default_team_member_models;
+ }
+
const response = await teamUpdateCall(accessToken, updateData);
NotificationsManager.success("Team settings updated successfully");
@@ -899,6 +910,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
accessGroups: info.object_permission?.agent_access_groups || [],
},
access_group_ids: info.access_group_ids || [],
+ default_team_member_models: info.default_team_member_models || [],
}}
layout="vertical"
>
@@ -946,44 +958,76 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
<Input placeholder="[email protected], [email protected]" />
</Form.Item>
- <Form.Item
- label="Team Member Budget (USD)"
- name="team_member_budget"
- tooltip="This is the individual budget for a user in the team."
- >
- <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
- </Form.Item>
-
- <Form.Item label="Team Member Budget Duration" name="team_member_budget_duration">
- <DurationSelect
- onChange={(value) => form.setFieldValue("team_member_budget_duration", value)}
- value={form.getFieldValue("team_member_budget_duration")}
- />
- </Form.Item>
-
- <Form.Item
- label="Team Member Key Duration (eg: 1d, 1mo)"
- name="team_member_key_duration"
- tooltip="Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)"
- >
- <TextInput placeholder="e.g., 30d" />
- </Form.Item>
-
- <Form.Item
- label="Team Member TPM Limit"
- name="team_member_tpm_limit"
- tooltip="Default tokens per minute limit for an individual team member. This limit applies to all requests the user makes within this team. Can be overridden per member."
- >
- <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 1000" />
- </Form.Item>
-
- <Form.Item
- label="Team Member RPM Limit"
- name="team_member_rpm_limit"
- tooltip="Default requests per minute limit for an individual team member. This limit applies to all requests the user makes within this team. Can be overridden per member."
- >
- <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 100" />
- </Form.Item>
+ <Accordion className="mt-4 mb-4">
+ <AccordionHeader>
+ <b>Team Member Settings</b>
+ </AccordionHeader>
+ <AccordionBody>
+ <Text className="text-xs text-gray-500 mb-4">
+ Optional defaults applied when members join this team. All fields can be overridden per member.
+ </Text>
+ <Form.Item
+ label={
+ <span>
+ Default Model Access{" "}
+ <Tooltip title="Optional. If set, new members can only access these models by default. Must be a subset of the team's models above. Leave empty to give all members access to all team models.">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ }
+ name="default_team_member_models"
+ >
+ <Form.Item noStyle shouldUpdate={(prev, cur) => prev.models !== cur.models}>
+ {({ getFieldValue }) => {
+ const teamModels = getFieldValue("models") || info.models || [];
+ return (
+ <Select
+ mode="multiple"
+ placeholder="Leave empty — all team models accessible to every member"
+ value={form.getFieldValue("default_team_member_models") || []}
+ onChange={(values) => form.setFieldValue("default_team_member_models", values)}
+ options={teamModels.map((m: string) => ({ label: m, value: m }))}
+ />
+ );
+ }}
+ </Form.Item>
+ </Form.Item>
+ <Form.Item
+ label="Default Budget (USD)"
+ name="team_member_budget"
+ tooltip="Default spend budget for each member in this team."
+ >
+ <NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
+ </Form.Item>
+ <Form.Item label="Default Budget Duration" name="team_member_budget_duration">
+ <DurationSelect
+ onChange={(value) => form.setFieldValue("team_member_budget_duration", value)}
+ value={form.getFieldValue("team_member_budget_duration")}
+ />
+ </Form.Item>
+ <Form.Item
+ label="Default Key Duration (eg: 1d, 1mo)"
+ name="team_member_key_duration"
+ tooltip="Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)"
+ >
+ <TextInput placeholder="e.g., 30d" />
+ </Form.Item>
+ <Form.Item
+ label="Default TPM Limit"
+ name="team_member_tpm_limit"
+ tooltip="Default tokens per minute limit for each member. Can be overridden per member."
+ >
+ <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 1000" />
+ </Form.Item>
+ <Form.Item
+ label="Default RPM Limit"
+ name="team_member_rpm_limit"
+ tooltip="Default requests per minute limit for each member. Can be overridden per member."
+ >
+ <NumericalInput step={1} style={{ width: "100%" }} placeholder="e.g., 100" />
+ </Form.Item>
+ </AccordionBody>
+ </Accordion>
<Form.Item label="Reset Budget" name="budget_duration">
<Select placeholder="n/a">
@@ -1318,6 +1362,18 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
))}
</div>
</div>
+ {info.default_team_member_models && info.default_team_member_models.length > 0 && (
+ <div>
+ <Text className="font-medium">Default Member Models</Text>
+ <div className="flex flex-wrap gap-2 mt-1">
+ {info.default_team_member_models.map((model, index) => (
+ <Badge key={index} color="blue">
+ {model}
+ </Badge>
+ ))}
+ </div>
+ </div>
+ )}
<div>
<Text className="font-medium">Rate Limits</Text>
<div>TPM: {info.tpm_limit || "Unlimited"}</div>
@@ -1483,6 +1539,20 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
min: 0,
placeholder: "Requests per minute limit for this member in this team",
},
+ {
+ name: "allowed_models",
+ label: (
+ <span>
+ Allowed Models{" "}
+ <Tooltip title="Models this member can access within this team. Leave empty to inherit all team models.">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ ),
+ type: "multi-select" as const,
+ options: (info.models || []).map((m: string) => ({ label: m, value: m })),
+ placeholder: "Leave empty to inherit all team models",
+ },
],
}}
/>
diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx
index 652d1dbcd91..e880aa49f65 100644
--- a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx
@@ -82,7 +82,45 @@ export default function TeamMemberTab({
const isUserTeamAdmin = isUserTeamAdminForSingleTeam(teamData.team_info.members_with_roles, userId || "");
const isProxyAdmin = isProxyAdminRole(userRole || "");
+ const getUserAllowedModels = (userId: string | null): string[] | null => {
+ if (!userId) return null;
+ const membership = teamData.team_memberships.find((tm) => tm.user_id === userId);
+ const models = membership?.litellm_budget_table?.allowed_models;
+ return models && models.length > 0 ? models : null;
+ };
+
const extraColumns: ColumnsType<Member> = [
+ {
+ title: (
+ <Space direction="horizontal">
+ Model Scope
+ <Tooltip title="Models this member can access. Empty means they inherit all team models.">
+ <InfoCircleOutlined />
+ </Tooltip>
+ </Space>
+ ),
+ key: "model_scope",
+ render: (_: unknown, record: Member) => {
+ const models = getUserAllowedModels(record.user_id);
+ if (!models) {
+ return <Typography.Text type="secondary">(all team models)</Typography.Text>;
+ }
+ const displayed = models.slice(0, 2);
+ const remaining = models.length - displayed.length;
+ return (
+ <Space wrap>
+ {displayed.map((m) => (
+ <Typography.Text key={m} code style={{ fontSize: "12px" }}>{m}</Typography.Text>
+ ))}
+ {remaining > 0 && (
+ <Tooltip title={models.slice(2).join(", ")}>
+ <Typography.Text type="secondary">+{remaining} more</Typography.Text>
+ </Tooltip>
+ )}
+ </Space>
+ );
+ },
+ },
{
title: (
<Space direction="horizontal">
@@ -138,6 +176,7 @@ export default function TeamMemberTab({
max_budget_in_team: membership?.litellm_budget_table?.max_budget || null,
tpm_limit: membership?.litellm_budget_table?.tpm_limit || null,
rpm_limit: membership?.litellm_budget_table?.rpm_limit || null,
+ allowed_models: membership?.litellm_budget_table?.allowed_models || [],
};
setSelectedEditMember(enhancedMember);
setIsEditMemberModalVisible(true);