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]

refactor(types): move GenerateRequestBase and LiteLLM_ObjectPermissionBase into litellm.types.proxy.management_endpoints.request_base (#45802)

nate-berri981710fab81c
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index 9ee20c22cef..0715a4cae97 100644
--- a/litellm/proxy/_types.py
+++ b/litellm/proxy/_types.py
@@ -1159,71 +1159,16 @@ class ModelParams(LiteLLMPydanticObjectBase):
return values
-class LiteLLM_ObjectPermissionBase(LiteLLMPydanticObjectBase):
- mcp_servers: list[str] | None = None
- mcp_access_groups: list[str] | None = None
- mcp_tool_permissions: dict[str, list[str]] | None = None
- mcp_toolsets: list[str] | None = None
- blocked_tools: list[str] | None = None
- vector_stores: list[str] | None = None
- agents: list[str] | None = None
- agent_access_groups: list[str] | None = None
- models: list[str] | None = None
- search_tools: list[str] | None = None
- mcp_tool_search_enabled: bool | None = None
- skills: list[str] | None = None
-
-
from litellm.models.team import BudgetLimitEntry as BudgetLimitEntry # noqa: E402
from litellm.types.object_permission import ( # noqa: E402
ObjectPermissionDict as ObjectPermissionDict,
)
-
-
-class GenerateRequestBase(LiteLLMPydanticObjectBase):
- """
- Overlapping schema between key and user generate/update requests
- """
-
- key_alias: str | None = None
- duration: str | None = None
- models: list[Any] | None = []
- spend: float | None = 0
- max_budget: float | None = None
- user_id: str | None = None
- team_id: str | None = None
- agent_id: str | None = None
- max_parallel_requests: int | None = None
- metadata: dict[Any, Any] | None = {}
- tpm_limit: int | None = None
- rpm_limit: int | None = None
-
- budget_duration: str | None = None
- budget_limits: list[BudgetLimitEntry] | None = None # multiple concurrent budget windows
- allowed_cache_controls: list[object] | None = []
- config: dict[object, object] | None = {}
- permissions: dict[object, object] | None = {}
- model_max_budget: dict[object, object] | None = {} # {"gpt-4": 5.0, "gpt-3.5-turbo": 5.0}, defaults to {}
- budget_fallbacks: dict[str, list[str]] | None = None
-
- model_config = ConfigDict(protected_namespaces=())
- model_rpm_limit: dict[object, object] | None = None
- model_tpm_limit: dict[object, object] | None = None
- mcp_rpm_limit: dict[str, int] | None = None
- tag_rpm_limit: dict[str, int] | None = None
- guardrails: list[str] | None = None
- policies: list[str] | None = None
- prompts: list[str] | None = None
- blocked: bool | None = None
- aliases: dict[object, object] | None = {}
- object_permission: LiteLLM_ObjectPermissionBase | None = None
-
- @field_validator("max_budget", mode="before")
- @classmethod
- def check_max_budget(cls, v: object) -> object:
- if v == "":
- return None
- return v
+from litellm.types.proxy.management_endpoints.request_base import ( # noqa: E402 # re-export after the definitions above
+ GenerateRequestBase as GenerateRequestBase, # noqa: PLC0414 # public re-export
+)
+from litellm.types.proxy.management_endpoints.request_base import ( # noqa: E402 # re-export after the definitions above
+ LiteLLM_ObjectPermissionBase as LiteLLM_ObjectPermissionBase, # noqa: PLC0414 # public re-export
+)
class AllowedVectorStoreIndexItem(LiteLLMPydanticObjectBase):
diff --git a/litellm/types/proxy/management_endpoints/request_base.py b/litellm/types/proxy/management_endpoints/request_base.py
new file mode 100644
index 00000000000..6b4a76e0132
--- /dev/null
+++ b/litellm/types/proxy/management_endpoints/request_base.py
@@ -0,0 +1,67 @@
+from typing import Any # noqa: TID251 # metadata and models stay Any so existing callers keep type-checking
+
+from pydantic import ConfigDict, field_validator
+
+from litellm.models.team import BudgetLimitEntry
+from litellm.types.utils import LiteLLMPydanticObjectBase
+
+
+class LiteLLM_ObjectPermissionBase(LiteLLMPydanticObjectBase):
+ mcp_servers: list[str] | None = None
+ mcp_access_groups: list[str] | None = None
+ mcp_tool_permissions: dict[str, list[str]] | None = None
+ mcp_toolsets: list[str] | None = None
+ blocked_tools: list[str] | None = None
+ vector_stores: list[str] | None = None
+ agents: list[str] | None = None
+ agent_access_groups: list[str] | None = None
+ models: list[str] | None = None
+ search_tools: list[str] | None = None
+ mcp_tool_search_enabled: bool | None = None
+ skills: list[str] | None = None
+
+
+class GenerateRequestBase(LiteLLMPydanticObjectBase):
+ """
+ Overlapping schema between key and user generate/update requests
+ """
+
+ key_alias: str | None = None
+ duration: str | None = None
+ models: list[Any] | None = []
+ spend: float | None = 0
+ max_budget: float | None = None
+ user_id: str | None = None
+ team_id: str | None = None
+ agent_id: str | None = None
+ max_parallel_requests: int | None = None
+ metadata: dict[Any, Any] | None = {}
+ tpm_limit: int | None = None
+ rpm_limit: int | None = None
+
+ budget_duration: str | None = None
+ budget_limits: list[BudgetLimitEntry] | None = None # multiple concurrent budget windows
+ allowed_cache_controls: list[object] | None = []
+ config: dict[object, object] | None = {}
+ permissions: dict[object, object] | None = {}
+ model_max_budget: dict[object, object] | None = {} # {"gpt-4": 5.0, "gpt-3.5-turbo": 5.0}, defaults to {}
+ budget_fallbacks: dict[str, list[str]] | None = None
+
+ model_config = ConfigDict(protected_namespaces=())
+ model_rpm_limit: dict[object, object] | None = None
+ model_tpm_limit: dict[object, object] | None = None
+ mcp_rpm_limit: dict[str, int] | None = None
+ tag_rpm_limit: dict[str, int] | None = None
+ guardrails: list[str] | None = None
+ policies: list[str] | None = None
+ prompts: list[str] | None = None
+ blocked: bool | None = None
+ aliases: dict[object, object] | None = {}
+ object_permission: LiteLLM_ObjectPermissionBase | None = None
+
+ @field_validator("max_budget", mode="before")
+ @classmethod
+ def check_max_budget(cls, v: object) -> object:
+ if v == "":
+ return None
+ return v