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]

Merge pull request #26442 from BerriAI/litellm_feat-restrict-org-admin-permissions

ryan-crabbe-berri419a34a900ff
diff --cc litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py
index caf8a00f10f,2c07d0927b6..eed4f076467
--- a/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py
+++ b/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py
@@@ -183,63 -191,9 +189,64 @@@ _RUNTIME_GENERAL_SETTINGS_FLAGS =
"allow_agents_for_team_admins",
"disable_vector_stores_for_internal_users",
"allow_vector_stores_for_team_admins",
+ "disable_key_generate_for_org_admin",
]
+# Extension point: packages outside OSS (e.g. litellm_enterprise) can
+# contribute additional UI settings fields at import time. Each entry
+# maps a field name to a (annotation, FieldInfo) tuple in pydantic
+# create_model's field-definitions format. Registering a field also
+# appends it to ALLOWED_UI_SETTINGS_FIELDS so GET/PATCH pass it through.
+#
+# The annotation is typed ``Any`` because pydantic field annotations
+# include generics like ``Optional[int]`` / ``List[str]`` that are not
+# instances of ``type`` — so tightening this to ``type`` would reject
+# valid inputs.
+_EXTRA_UI_SETTINGS_FIELDS: Dict[str, Tuple[Any, FieldInfo]] = {}
+
+# Settings OSS knows about as enterprise-gated. If a caller sends one of
+# these keys and no extension package has registered it, the PATCH
+# endpoint returns 403 instead of silently dropping the value, so the
+# client gets a clear signal that the feature requires LiteLLM Enterprise.
+_ENTERPRISE_ONLY_UI_SETTINGS: Set[str] = {"enable_projects_ui"}
+
+# Memoized effective class; invalidated on registration.
+_EFFECTIVE_UI_SETTINGS_CLASS: Optional[Type[UISettings]] = None
+
+
+def register_extra_ui_setting(name: str, annotation: Any, field: FieldInfo) -> None:
+ """Register an additional UI settings field contributed by an extension package.
+
+ ``field`` must be a ``FieldInfo`` instance — construct it directly
+ (e.g. ``FieldInfo(default=..., description=...)``) rather than via
+ the ``pydantic.Field`` factory, whose stub reports the default's
+ type instead of ``FieldInfo`` and trips mypy at the call site.
+ """
+ global _EFFECTIVE_UI_SETTINGS_CLASS
+ _EXTRA_UI_SETTINGS_FIELDS[name] = (annotation, field)
+ ALLOWED_UI_SETTINGS_FIELDS.add(name)
+ _EFFECTIVE_UI_SETTINGS_CLASS = None
+
+
+def _get_effective_ui_settings_class() -> Type[UISettings]:
+ """Return UISettings with any extension-registered fields merged in.
+
+ Memoized — pydantic ``create_model`` runs metaclass + schema work
+ each call, so we cache until a new registration invalidates it.
+ """
+ global _EFFECTIVE_UI_SETTINGS_CLASS
+ if _EFFECTIVE_UI_SETTINGS_CLASS is not None:
+ return _EFFECTIVE_UI_SETTINGS_CLASS
+ if not _EXTRA_UI_SETTINGS_FIELDS:
+ return UISettings
+ _EFFECTIVE_UI_SETTINGS_CLASS = create_model( # type: ignore[call-overload]
+ "EffectiveUISettings",
+ __base__=UISettings,
+ __doc__=UISettings.__doc__,
+ **_EXTRA_UI_SETTINGS_FIELDS,
+ )
+ return _EFFECTIVE_UI_SETTINGS_CLASS
+
class MCPSemanticFilterSettings(BaseModel):
"""Configuration for MCP Semantic Tool Filter"""