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
chore(proxy): preserve readiness compatibility
userb31182f62a20
diff --git a/litellm/proxy/health_endpoints/_health_endpoints.py b/litellm/proxy/health_endpoints/_health_endpoints.pyindex 6387d1b546f..0f7067b1c25 100644--- a/litellm/proxy/health_endpoints/_health_endpoints.py+++ b/litellm/proxy/health_endpoints/_health_endpoints.py@@ -1306,6 +1306,12 @@ async def _get_health_readiness_details() -> Dict[str, Any]:raise HTTPException(status_code=503, detail=f"Service Unhealthy ({str(e)})")+def _allow_public_health_readiness_details() -> bool:+ from litellm.proxy.proxy_server import general_settings++ return general_settings.get("allow_public_health_readiness_details") is True++@router.get("/health/readiness",tags=["health"],@@ -1313,8 +1319,11 @@ async def _get_health_readiness_details() -> Dict[str, Any]:async def health_readiness():"""Public readiness probe. Keep this low-detail for unauthenticated load- balancers while preserving the existing unauthenticated probe contract.+ balancers by default. Admins can opt into the legacy detailed public+ payload with general_settings.allow_public_health_readiness_details."""+ if _allow_public_health_readiness_details():+ return await _get_health_readiness_details()return {"status": "healthy"}diff --git a/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py b/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.pyindex 7354971e527..da500252d74 100644--- a/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py+++ b/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py@@ -99,6 +99,11 @@ class UISettings(BaseModel):description="If true, requires authentication for accessing the public AI Hub.",)+ allow_public_health_readiness_details: bool = Field(+ default=False,+ description="If true, returns the legacy detailed payload from the unauthenticated /health/readiness endpoint.",+ )+forward_client_headers_to_llm_api: bool = Field(default=False,description=(@@ -169,6 +174,7 @@ ALLOWED_UI_SETTINGS_FIELDS = {"disable_team_admin_delete_team_user","enabled_ui_pages_internal_users","require_auth_for_public_ai_hub",+ "allow_public_health_readiness_details","forward_client_headers_to_llm_api","forward_llm_provider_auth_headers","disable_agents_for_internal_users",@@ -184,6 +190,7 @@ ALLOWED_UI_SETTINGS_FIELDS = {# general_settings at runtime (on both read and write)._RUNTIME_GENERAL_SETTINGS_FLAGS = ["require_auth_for_public_ai_hub",+ "allow_public_health_readiness_details","forward_client_headers_to_llm_api","forward_llm_provider_auth_headers","disable_agents_for_internal_users",diff --git a/tests/test_health.py b/tests/test_health.pyindex 39c249370fa..15dc2330ffb 100644--- a/tests/test_health.py+++ b/tests/test_health.py@@ -79,6 +79,26 @@ async def test_health_readiness():raise Exception(f"Request did not return a 200 status code: {status}")+async def test_health_readiness_details():+ """+ Check if authenticated readiness diagnostics expose version metadata.+ """+ async with aiohttp.ClientSession() as session:+ url = "http://0.0.0.0:4000/health/readiness/details"+ headers = {"Authorization": "Bearer sk-1234"}+ async with session.get(url, headers=headers) as response:+ status = response.status+ response_json = await response.json()++ print(response_json)+ assert "status" in response_json+ assert "litellm_version" in response_json++ if status != 200:+ raise Exception(f"Request did not return a 200 status code: {status}")++@pytest.mark.asyncioasync def test_health_liveliness():"""diff --git a/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py b/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.pyindex d3c22ad6091..d275b02e343 100644--- a/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py+++ b/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py@@ -643,6 +643,30 @@ def test_health_readiness_details_returns_diagnostic_fields(monkeypatch):assert "cache" in response_data+def test_health_readiness_allows_explicit_legacy_public_details(monkeypatch):+ """+ Operators can explicitly preserve the legacy public readiness payload.+ """+ app = FastAPI()+ app.include_router(_health_endpoints_module.router)+ client = TestClient(app)++ monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", None)+ monkeypatch.setattr(+ "litellm.proxy.proxy_server.general_settings",+ {"allow_public_health_readiness_details": True},+ )++ response = client.get("/health/readiness")++ assert response.status_code == 200, response.text+ response_data = response.json()+ assert response_data["status"] == "healthy"+ assert "litellm_version" in response_data+ assert "success_callbacks" in response_data+ assert "cache" in response_data++def test_get_callback_identifier_string_and_object_with_callback_name():"""Test get_callback_identifier with string callbacks and objects with callback_name attribute.diff --git a/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py b/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.pyindex bd35488fc3f..256782c714f 100644--- a/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py+++ b/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py@@ -1184,6 +1184,43 @@ class TestProxySettingEndpoints:assert response.status_code == 200assert general_settings.get("require_auth_for_public_ai_hub") is True+ def test_update_ui_settings_syncs_public_health_readiness_details_to_general_settings(+ self, mock_auth, monkeypatch+ ):+ """Public readiness details flag must be synced so the health route sees it."""+ from unittest.mock import AsyncMock, MagicMock++ from litellm.proxy._types import UserAPIKeyAuth+ from litellm.proxy.auth.user_api_key_auth import user_api_key_auth++ mock_user_auth = UserAPIKeyAuth(+ user_id="test-user-123",+ user_role=LitellmUserRoles.PROXY_ADMIN,+ )+ app.dependency_overrides[user_api_key_auth] = lambda: mock_user_auth++ monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", True)++ general_settings: dict = {}+ monkeypatch.setattr(+ "litellm.proxy.proxy_server.general_settings", general_settings+ )++ mock_prisma = MagicMock()+ mock_prisma.db.litellm_uisettings.upsert = AsyncMock()+ mock_prisma.db.litellm_uisettings.find_unique = AsyncMock(return_value=None)+ monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", mock_prisma)++ payload = {"allow_public_health_readiness_details": True}++ try:+ response = client.patch("/update/ui_settings", json=payload)+ finally:+ app.dependency_overrides.clear()++ assert response.status_code == 200+ assert general_settings.get("allow_public_health_readiness_details") is True+def test_update_ui_settings_persists_and_syncs_disable_key_generate_for_org_admin(self, mock_auth, monkeypatch):