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]

correct use of healthy / unhealthy

Ishaan Jafffd7014a326c9
diff --git a/docs/my-website/docs/proxy/team_logging.md b/docs/my-website/docs/proxy/team_logging.md
index 3221100bef9..62d22588277 100644
--- a/docs/my-website/docs/proxy/team_logging.md
+++ b/docs/my-website/docs/proxy/team_logging.md
@@ -338,7 +338,7 @@ Response when logging callbacks are setup correctly:
Response when logging callbacks are not setup correctly:
```json
{
- "key": "healthy",
+ "key": "unhealthy",
"logging_callbacks": {
"callbacks": [
"gcs_bucket"
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index c3b9bc00cc5..36489f8a438 100644
--- a/litellm/proxy/_types.py
+++ b/litellm/proxy/_types.py
@@ -1927,10 +1927,10 @@ class CurrentItemRateLimit(TypedDict):
class LoggingCallbackStatus(TypedDict, total=False):
callbacks: List[str]
- status: str
+ status: Literal["healthy", "unhealthy"]
details: Optional[str]
class KeyHealthResponse(TypedDict, total=False):
- key: str
+ key: Literal["healthy", "unhealthy"]
logging_callbacks: Optional[LoggingCallbackStatus]
diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py
index 133affa8c55..152de4edf7c 100644
--- a/litellm/proxy/management_endpoints/key_management_endpoints.py
+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py
@@ -1496,7 +1496,7 @@ async def key_health(
Response when logging callbacks are not setup correctly:
```json
{
- "key": "healthy",
+ "key": "unhealthy",
"logging_callbacks": {
"callbacks": [
"gcs_bucket"
@@ -1525,6 +1525,10 @@ async def key_health(
)
health_status["logging_callbacks"] = logging_statuses
+ # Check if any logging callback is unhealthy
+ if logging_statuses.get("status") == "unhealthy":
+ health_status["key"] = "unhealthy"
+
return KeyHealthResponse(**health_status)
except Exception as e:
@@ -1591,7 +1595,7 @@ async def test_key_logging(
except Exception as e:
return LoggingCallbackStatus(
callbacks=logging_callbacks,
- status="error",
+ status="unhealthy",
details=f"Logging test failed: {str(e)}",
)