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]

Control Plane + Data Plane support (#12601)

Krish Dholakia7c392475e6c9
diff --git a/docs/my-website/docs/proxy/control_plane_and_data_plane.md b/docs/my-website/docs/proxy/control_plane_and_data_plane.md
new file mode 100644
index 00000000000..75f4e9ea954
--- /dev/null
+++ b/docs/my-website/docs/proxy/control_plane_and_data_plane.md
@@ -0,0 +1,212 @@
+import Image from '@theme/IdealImage';
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+# Control Plane and Data Plane (Enterprise)
+
+Learn how to deploy LiteLLM across multiple instances while maintaining centralized administration and avoiding duplication of management overhead.
+
+:::info
+
+✨ This requires LiteLLM Enterprise features.
+
+[Enterprise Pricing](https://www.litellm.ai/#pricing)
+
+[Get free 7-day trial key](https://www.litellm.ai/enterprise#trial)
+
+:::
+
+## Overview
+
+When scaling LiteLLM for production use, you may want to deploy multiple instances across different regions or availability zones while maintaining a single point of administration. This guide covers how to set up a distributed LiteLLM deployment with:
+
+- **Regional Worker Instances**: Handle LLM requests for users in specific regions
+- **Centralized Admin Instance**: Manages configuration, users, keys, and monitoring
+
+## Architecture Pattern: Regional + Admin Instances
+
+### Typical Deployment Scenario
+
+<Image img={require('../../img/scaling_architecture.png')} />
+
+### Benefits of This Architecture
+
+1. **Reduced Management Overhead**: Only one instance needs admin capabilities
+2. **Regional Performance**: Users get low-latency access from their region
+3. **Centralized Control**: All administration happens from a single interface
+4. **Security**: Limit admin access to designated instances only
+5. **Cost Efficiency**: Avoid duplicating admin infrastructure
+
+## Configuration
+
+### Admin Instance Configuration
+
+The admin instance handles all management operations and provides the UI.
+
+**Environment Variables for Admin Instance:**
+```bash
+# Keep admin capabilities enabled (default behavior)
+# DISABLE_ADMIN_UI=false # Admin UI available
+# DISABLE_ADMIN_ENDPOINTS=false # Management APIs available
+DISABLE_LLM_ENDPOINTS=true # LLM APIs disabled
+DATABASE_URL=postgresql://user:pass@global-db:5432/litellm
+LITELLM_MASTER_KEY=your-master-key
+```
+
+### Worker Instance Configuration
+
+Worker instances handle LLM requests but have admin capabilities disabled.
+
+**Environment Variables for Worker Instances:**
+```bash
+# Disable admin capabilities
+DISABLE_ADMIN_UI=true # No admin UI
+DISABLE_ADMIN_ENDPOINTS=true # No management endpoints
+
+DATABASE_URL=postgresql://user:pass@global-db:5432/litellm
+LITELLM_MASTER_KEY=your-master-key
+```
+
+## Environment Variables Reference
+
+### `DISABLE_ADMIN_UI`
+
+Disables the LiteLLM Admin UI interface.
+
+- **Default**: `false`
+- **Worker Instances**: Set to `true`
+- **Admin Instance**: Leave as `false` (or don't set)
+
+```bash
+# Worker instances
+DISABLE_ADMIN_UI=true
+```
+
+**Effect**: When enabled, the web UI at `/ui` becomes unavailable.
+
+### `DISABLE_ADMIN_ENDPOINTS`
+
+:::info
+
+✨ This is an Enterprise feature.
+
+[Enterprise Pricing](https://www.litellm.ai/#pricing)
+
+[Get free 7-day trial key](https://www.litellm.ai/enterprise#trial)
+
+:::
+
+Disables all management/admin API endpoints.
+
+- **Default**: `false`
+- **Worker Instances**: Set to `true`
+- **Admin Instance**: Leave as `false` (or don't set)
+
+```bash
+# Worker instances
+DISABLE_ADMIN_ENDPOINTS=true
+```
+
+**Disabled Endpoints Include**:
+- `/key/*` - Key management
+- `/user/*` - User management
+- `/team/*` - Team management
+- `/config/*` - Configuration updates
+- All other administrative endpoints
+
+**Available Endpoints** (when disabled):
+- `/chat/completions` - LLM requests
+- `/v1/*` - OpenAI-compatible APIs
+- `/vertex_ai/*` - Vertex AI pass-through APIs
+- `/bedrock/*` - Bedrock pass-through APIs
+- `/health` - Basic health check
+- `/metrics` - Prometheus metrics
+- All other LLM API endpoints
+
+
+### `DISABLE_LLM_ENDPOINTS`
+
+:::info
+
+✨ This is an Enterprise feature.
+
+[Enterprise Pricing](https://www.litellm.ai/#pricing)
+
+[Get free 7-day trial key](https://www.litellm.ai/enterprise#trial)
+
+:::
+
+Disables all LLM API endpoints.
+
+- **Default**: `false`
+- **Worker Instances**: Leave as `false` (or don't set)
+- **Admin Instance**: Set to `true`
+
+```bash
+# Admin instance
+DISABLE_LLM_ENDPOINTS=true
+```
+
+
+**Disabled Endpoints Include**:
+- `/chat/completions` - LLM requests
+- `/v1/*` - OpenAI-compatible APIs
+- `/vertex_ai/*` - Vertex AI pass-through APIs
+- `/bedrock/*` - Bedrock pass-through APIs
+- `/health` - Basic health check
+- `/metrics` - Prometheus metrics
+- All other LLM API endpoints
+
+
+**Available Endpoints** (when disabled):
+- `/key/*` - Key management
+- `/user/*` - User management
+- `/team/*` - Team management
+- `/config/*` - Configuration updates
+- All other administrative endpoints
+
+
+## Usage Patterns
+
+### Client Usage
+
+**For LLM Requests** (use regional endpoints):
+```python
+import openai
+
+# US users
+client_us = openai.OpenAI(
+ base_url="https://us.company.com/v1",
+ api_key="your-litellm-key"
+)
+
+# EU users
+client_eu = openai.OpenAI(
+ base_url="https://eu.company.com/v1",
+ api_key="your-litellm-key"
+)
+
+response = client_us.chat.completions.create(
+ model="gpt-4",
+ messages=[{"role": "user", "content": "Hello!"}]
+)
+```
+
+**For Administration** (use admin endpoint):
+```python
+import requests
+
+# Create a new API key
+response = requests.post(
+ "https://admin.company.com/key/generate",
+ headers={"Authorization": "Bearer sk-1234"},
+ json={"duration": "30d"}
+)
+```
+
+## Related Documentation
+
+- [Virtual Keys](./virtual_keys.md) - Managing API keys and users
+- [Health Checks](./health.md) - Monitoring instance health
+- [Prometheus Metrics](./logging.md#prometheus-metrics) - Collecting metrics
+- [Production Deployment](./prod.md) - Production best practices
\ No newline at end of file
diff --git a/docs/my-website/img/scaling_architecture.png b/docs/my-website/img/scaling_architecture.png
new file mode 100644
index 00000000000..a4ae012cc57
Binary files /dev/null and b/docs/my-website/img/scaling_architecture.png differ
diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js
index e560059027c..f9753b8fa2f 100644
--- a/docs/my-website/sidebars.js
+++ b/docs/my-website/sidebars.js
@@ -116,7 +116,7 @@ const sidebars = {
{
type: "category",
label: "Architecture",
- items: ["proxy/architecture", "proxy/db_info", "proxy/db_deadlocks", "router_architecture", "proxy/user_management_heirarchy", "proxy/jwt_auth_arch", "proxy/image_handling", "proxy/spend_logs_deletion"],
+ items: ["proxy/architecture", "proxy/control_plane_and_data_plane", "proxy/db_info", "proxy/db_deadlocks", "router_architecture", "proxy/user_management_heirarchy", "proxy/jwt_auth_arch", "proxy/image_handling", "proxy/spend_logs_deletion"],
},
{
type: "link",
diff --git a/enterprise/litellm_enterprise/proxy/auth/route_checks.py b/enterprise/litellm_enterprise/proxy/auth/route_checks.py
new file mode 100644
index 00000000000..1d4bfc664d5
--- /dev/null
+++ b/enterprise/litellm_enterprise/proxy/auth/route_checks.py
@@ -0,0 +1,67 @@
+import os
+
+from fastapi import HTTPException, status
+
+
+class EnterpriseRouteChecks:
+ @staticmethod
+ def is_llm_api_route_disabled() -> bool:
+ """
+ Check if llm api route is disabled
+ """
+ from litellm.proxy._types import CommonProxyErrors
+ from litellm.proxy.proxy_server import premium_user
+ from litellm.secret_managers.main import get_secret_bool
+
+ ## Check if DISABLE_LLM_API_ENDPOINTS is set
+ if "DISABLE_LLM_API_ENDPOINTS" in os.environ:
+ if not premium_user:
+ raise HTTPException(
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
+ detail=f"🚨🚨🚨 DISABLING LLM API ENDPOINTS is an Enterprise feature\n🚨 {CommonProxyErrors.not_premium_user.value}",
+ )
+ return False
+
+ return get_secret_bool("DISABLE_LLM_API_ENDPOINTS") is True
+
+ @staticmethod
+ def is_management_routes_disabled() -> bool:
+ """
+ Check if management route is disabled
+ """
+ from litellm.proxy._types import CommonProxyErrors
+ from litellm.proxy.proxy_server import premium_user
+ from litellm.secret_managers.main import get_secret_bool
+
+ if "DISABLE_ADMIN_ENDPOINTS" in os.environ:
+ if not premium_user:
+ raise HTTPException(
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
+ detail=f"🚨🚨🚨 DISABLING LLM API ENDPOINTS is an Enterprise feature\n🚨 {CommonProxyErrors.not_premium_user.value}",
+ )
+
+ return get_secret_bool("DISABLE_ADMIN_ENDPOINTS") is True
+
+ @staticmethod
+ def should_call_route(route: str):
+ """
+ Check if management route is disabled and raise exception
+ """
+ from litellm.proxy.auth.route_checks import RouteChecks
+
+ if (
+ RouteChecks.is_management_route(route=route)
+ and EnterpriseRouteChecks.is_management_routes_disabled()
+ ):
+ raise HTTPException(
+ status_code=status.HTTP_403_FORBIDDEN,
+ detail="Management routes are disabled for this instance.",
+ )
+ elif (
+ RouteChecks.is_llm_api_route(route=route)
+ and EnterpriseRouteChecks.is_llm_api_route_disabled()
+ ):
+ raise HTTPException(
+ status_code=status.HTTP_403_FORBIDDEN,
+ detail="LLM API routes are disabled for this instance.",
+ )
diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py
index cf637ce1087..5b50ce07305 100644
--- a/litellm/proxy/auth/auth_checks.py
+++ b/litellm/proxy/auth/auth_checks.py
@@ -288,10 +288,8 @@ def _is_api_route_allowed(
if valid_token is None:
raise Exception("Invalid proxy server token passed. valid_token=None.")
- # Check if Virtual Key is allowed to call the route - Applies to all Roles
- RouteChecks.is_virtual_key_allowed_to_call_route(
- route=route, valid_token=valid_token
- )
+ # Check if management routes are disabled and raise exception if they are
+ RouteChecks.should_call_route(route=route, valid_token=valid_token)
if not _is_user_proxy_admin(user_obj=user_obj): # if non-admin
RouteChecks.non_proxy_admin_allowed_routes_check(
diff --git a/litellm/proxy/auth/route_checks.py b/litellm/proxy/auth/route_checks.py
index 083a93641e4..76c8d2f7cdc 100644
--- a/litellm/proxy/auth/route_checks.py
+++ b/litellm/proxy/auth/route_checks.py
@@ -16,6 +16,24 @@ from .auth_checks_organization import _user_is_org_admin
class RouteChecks:
+ @staticmethod
+ def should_call_route(route: str, valid_token: UserAPIKeyAuth):
+ """
+ Check if management route is disabled and raise exception
+ """
+ try:
+ from litellm_enterprise.proxy.auth.route_checks import EnterpriseRouteChecks
+
+ EnterpriseRouteChecks.should_call_route(route=route)
+ except Exception:
+ pass
+
+ # Check if Virtual Key is allowed to call the route - Applies to all Roles
+ RouteChecks.is_virtual_key_allowed_to_call_route(
+ route=route, valid_token=valid_token
+ )
+ return True
+
@staticmethod
def is_virtual_key_allowed_to_call_route(
route: str, valid_token: UserAPIKeyAuth
@@ -227,6 +245,13 @@ class RouteChecks:
return False
+ @staticmethod
+ def is_management_route(route: str) -> bool:
+ """
+ Check if route is a management route
+ """
+ return route in LiteLLMRoutes.management_routes.value
+
@staticmethod
def _is_azure_openai_route(route: str) -> bool:
"""
diff --git a/tests/enterprise/litellm_enterprise/proxy/auth/test_route_checks.py b/tests/enterprise/litellm_enterprise/proxy/auth/test_route_checks.py
new file mode 100644
index 00000000000..ce77ff69e05
--- /dev/null
+++ b/tests/enterprise/litellm_enterprise/proxy/auth/test_route_checks.py
@@ -0,0 +1,182 @@
+import os
+import sys
+from unittest.mock import MagicMock, patch
+
+sys.path.insert(
+ 0, os.path.abspath("../../../..")
+) # Adds the parent directory to the system path
+
+import pytest
+from fastapi import HTTPException
+
+# Import the enterprise route checks
+from litellm_enterprise.proxy.auth.route_checks import EnterpriseRouteChecks
+
+
+@patch("litellm.proxy.proxy_server.premium_user", True)
+class TestEnterpriseRouteChecks:
+
+ @patch.object(EnterpriseRouteChecks, "is_management_routes_disabled")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_management_route")
+ def test_should_call_route_management_disabled(
+ self, mock_is_management_route, mock_is_management_disabled
+ ):
+ """Test that should_call_route raises HTTPException when management routes are disabled and route is a management route"""
+
+ # Mock the methods to return True (route is management route and management is disabled)
+ mock_is_management_route.return_value = True
+ mock_is_management_disabled.return_value = True
+
+ # Test that calling should_call_route raises HTTPException with 403 status
+ with pytest.raises(HTTPException) as exc_info:
+ EnterpriseRouteChecks.should_call_route("/config/update")
+
+ # Verify the exception has correct status and message
+ assert exc_info.value.status_code == 403
+ assert "Management routes are disabled for this instance." in str(
+ exc_info.value.detail
+ )
+
+ @patch.object(EnterpriseRouteChecks, "is_llm_api_route_disabled")
+ @patch.object(EnterpriseRouteChecks, "is_management_routes_disabled")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_llm_api_route")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_management_route")
+ def test_should_call_route_llm_api_disabled(
+ self,
+ mock_is_management_route,
+ mock_is_llm_api_route,
+ mock_is_management_disabled,
+ mock_is_llm_api_disabled,
+ ):
+ """Test that should_call_route raises HTTPException when LLM API routes are disabled and route is an LLM API route"""
+
+ # Mock the methods - not a management route but is an LLM API route that's disabled
+ mock_is_management_route.return_value = False
+ mock_is_llm_api_route.return_value = True
+ mock_is_management_disabled.return_value = False
+ mock_is_llm_api_disabled.return_value = True
+
+ # Test that calling should_call_route raises HTTPException with 403 status
+ with pytest.raises(HTTPException) as exc_info:
+ EnterpriseRouteChecks.should_call_route("/v1/chat/completions")
+
+ # Verify the exception has correct status and message
+ assert exc_info.value.status_code == 403
+ assert "LLM API routes are disabled for this instance." in str(
+ exc_info.value.detail
+ )
+
+ @patch.object(EnterpriseRouteChecks, "is_llm_api_route_disabled")
+ @patch.object(EnterpriseRouteChecks, "is_management_routes_disabled")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_llm_api_route")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_management_route")
+ def test_should_call_route_both_disabled_management_takes_priority(
+ self,
+ mock_is_management_route,
+ mock_is_llm_api_route,
+ mock_is_management_disabled,
+ mock_is_llm_api_disabled,
+ ):
+ """Test that management route check takes priority when both are disabled"""
+
+ # Mock the methods - route is both management and LLM API, and both are disabled
+ mock_is_management_route.return_value = True
+ mock_is_llm_api_route.return_value = True
+ mock_is_management_disabled.return_value = True
+ mock_is_llm_api_disabled.return_value = True
+
+ # Test that calling should_call_route raises HTTPException with management route message
+ with pytest.raises(HTTPException) as exc_info:
+ EnterpriseRouteChecks.should_call_route("/config/update")
+
+ # Verify the exception has correct status and management route message (not LLM API message)
+ assert exc_info.value.status_code == 403
+ assert "Management routes are disabled for this instance." in str(
+ exc_info.value.detail
+ )
+
+ @patch.object(EnterpriseRouteChecks, "is_llm_api_route_disabled")
+ @patch.object(EnterpriseRouteChecks, "is_management_routes_disabled")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_llm_api_route")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_management_route")
+ def test_should_call_route_enabled(
+ self,
+ mock_is_management_route,
+ mock_is_llm_api_route,
+ mock_is_management_disabled,
+ mock_is_llm_api_disabled,
+ ):
+ """Test that should_call_route succeeds when routes are enabled"""
+
+ # Test case 1: Management route enabled
+ mock_is_management_route.return_value = True
+ mock_is_llm_api_route.return_value = False
+ mock_is_management_disabled.return_value = False
+ mock_is_llm_api_disabled.return_value = False
+
+ # Should not raise exception
+ EnterpriseRouteChecks.should_call_route("/config/update")
+
+ # Test case 2: LLM API route enabled
+ mock_is_management_route.return_value = False
+ mock_is_llm_api_route.return_value = True
+ mock_is_management_disabled.return_value = False
+ mock_is_llm_api_disabled.return_value = False
+
+ # Should not raise exception
+ EnterpriseRouteChecks.should_call_route("/v1/chat/completions")
+
+ # Test case 3: Neither management nor LLM API route
+ mock_is_management_route.return_value = False
+ mock_is_llm_api_route.return_value = False
+ mock_is_management_disabled.return_value = (
+ True # These can be True since route doesn't match
+ )
+ mock_is_llm_api_disabled.return_value = True
+
+ # Should not raise exception
+ EnterpriseRouteChecks.should_call_route("/health")
+
+ @patch.object(EnterpriseRouteChecks, "is_llm_api_route_disabled")
+ @patch.object(EnterpriseRouteChecks, "is_management_routes_disabled")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_llm_api_route")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_management_route")
+ def test_should_call_route_management_disabled_llm_enabled(
+ self,
+ mock_is_management_route,
+ mock_is_llm_api_route,
+ mock_is_management_disabled,
+ mock_is_llm_api_disabled,
+ ):
+ """Test that LLM API routes work when only management routes are disabled"""
+
+ # Mock the methods - LLM API route but management disabled, LLM API enabled
+ mock_is_management_route.return_value = False
+ mock_is_llm_api_route.return_value = True
+ mock_is_management_disabled.return_value = True
+ mock_is_llm_api_disabled.return_value = False
+
+ # Should not raise exception since LLM API routes are enabled
+ EnterpriseRouteChecks.should_call_route("/v1/chat/completions")
+
+ @patch.object(EnterpriseRouteChecks, "is_llm_api_route_disabled")
+ @patch.object(EnterpriseRouteChecks, "is_management_routes_disabled")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_llm_api_route")
+ @patch("litellm.proxy.auth.route_checks.RouteChecks.is_management_route")
+ def test_should_call_route_llm_disabled_management_enabled(
+ self,
+ mock_is_management_route,
+ mock_is_llm_api_route,
+ mock_is_management_disabled,
+ mock_is_llm_api_disabled,
+ ):
+ """Test that management routes work when only LLM API routes are disabled"""
+
+ # Mock the methods - management route but LLM API disabled, management enabled
+ mock_is_management_route.return_value = True
+ mock_is_llm_api_route.return_value = False
+ mock_is_management_disabled.return_value = False
+ mock_is_llm_api_disabled.return_value = True
+
+ # Should not raise exception since management routes are enabled
+ EnterpriseRouteChecks.should_call_route("/config/update")
diff --git a/tests/test_litellm/proxy/auth/test_route_checks.py b/tests/test_litellm/proxy/auth/test_route_checks.py
index a6358e73c36..42838f02f62 100644
--- a/tests/test_litellm/proxy/auth/test_route_checks.py
+++ b/tests/test_litellm/proxy/auth/test_route_checks.py
@@ -1,7 +1,7 @@
import asyncio
import os
import sys
-from unittest.mock import MagicMock
+from unittest.mock import MagicMock, patch
sys.path.insert(
0, os.path.abspath("../../..")