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
allow adding auth on /metrics endpoint
Ishaan Jaff86b473d26708
diff --git a/litellm/proxy/middleware/prometheus_auth_middleware.py b/litellm/proxy/middleware/prometheus_auth_middleware.pyindex ca38a9d4452..9e5a8ffcc8b 100644--- a/litellm/proxy/middleware/prometheus_auth_middleware.py+++ b/litellm/proxy/middleware/prometheus_auth_middleware.py@@ -2,6 +2,7 @@Prometheus Auth Middleware"""from fastapi import Request+from fastapi.responses import JSONResponsefrom starlette.middleware.base import BaseHTTPMiddlewareimport litellm@@ -24,7 +25,10 @@ class PrometheusAuthMiddleware(BaseHTTPMiddleware):or "",)except Exception as e:- raise e+ return JSONResponse(+ status_code=401,+ content=f"Unauthorized access to metrics endpoint: {getattr(e, 'message', str(e))}",+ )# Process the request and get the responseresponse = await call_next(request)diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yamlindex 61950f55fe3..788bf9642d5 100644--- a/litellm/proxy/proxy_config.yaml+++ b/litellm/proxy/proxy_config.yaml@@ -10,5 +10,6 @@ model_list:api_key: fake-keylitellm_settings:+ require_auth_for_metrics_endpoint: truecallbacks: ["prometheus"]service_callback: ["prometheus_system"]\ No newline at end of file