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
Add license metadata to health/readiness endpoint. (#15997)
Andrew Bernatd89990e0c5e4
diff --git a/litellm/proxy/health_endpoints/_health_endpoints.py b/litellm/proxy/health_endpoints/_health_endpoints.pyindex c59e91aa1ef..b42f800734a 100644--- a/litellm/proxy/health_endpoints/_health_endpoints.py+++ b/litellm/proxy/health_endpoints/_health_endpoints.py@@ -831,6 +831,28 @@ async def health_readiness():index_info = "index does not exist - error: " + str(e)cache_type = {"type": cache_type, "index_info": index_info}+ # build license metadata+ try:+ from litellm.proxy.proxy_server import _license_check # type: ignore++ license_available: bool = _license_check.is_premium() if _license_check else False+ license_expiration: Optional[str] = None++ if getattr(_license_check, "airgapped_license_data", None):+ license_expiration = _license_check.airgapped_license_data.get( # type: ignore[arg-type]+ "expiration_date"+ )++ license_metadata = {+ "license": {+ "has_license": license_available,+ "expiration_date": license_expiration,+ }+ }+ except Exception:+ # fail closed: don't let license check break readiness+ license_metadata = {"license": {"has_license": False, "expiration_date": None}}+# check DBif prisma_client is not None: # if db passed in, check if it's connecteddb_health_status = await _db_health_readiness_check()@@ -841,6 +863,7 @@ async def health_readiness():"litellm_version": version,"success_callbacks": success_callback_names,"use_aiohttp_transport": AsyncHTTPHandler._should_use_aiohttp_transport(),+ **license_metadata,**db_health_status,}else:@@ -851,6 +874,7 @@ async def health_readiness():"litellm_version": version,"success_callbacks": success_callback_names,"use_aiohttp_transport": AsyncHTTPHandler._should_use_aiohttp_transport(),+ **license_metadata,}except Exception as e:raise HTTPException(status_code=503, detail=f"Service Unhealthy ({str(e)})")diff --git a/tests/basic_proxy_startup_tests/test_basic_proxy_startup.py b/tests/basic_proxy_startup_tests/test_basic_proxy_startup.pyindex db09e38ea95..ef6e337a7a6 100644--- a/tests/basic_proxy_startup_tests/test_basic_proxy_startup.py+++ b/tests/basic_proxy_startup_tests/test_basic_proxy_startup.py@@ -25,6 +25,10 @@ async def test_health_and_chat_completion():readiness_response = await response.json()assert readiness_response["status"] == "connected"+ # New assertion: license metadata is present+ assert "license" in readiness_response+ assert "has_license" in readiness_response["license"]+# Test liveness endpointasync with session.get("http://0.0.0.0:4000/health/liveness") as response:assert response.status == 200