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]

PrometheusAuthMiddleware

Ishaan Jaffeaad3b240237
diff --git a/litellm/proxy/middleware/prometheus_auth_middleware.py b/litellm/proxy/middleware/prometheus_auth_middleware.py
index 9e5a8ffcc8b..5d7913e5bf3 100644
--- a/litellm/proxy/middleware/prometheus_auth_middleware.py
+++ b/litellm/proxy/middleware/prometheus_auth_middleware.py
@@ -11,6 +11,19 @@ from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
class PrometheusAuthMiddleware(BaseHTTPMiddleware):
+ """
+ Middleware to authenticate requests to the metrics endpoint
+
+ By default, auth is not run on the metrics endpoint
+
+ Enabled by setting the following in proxy_config.yaml:
+
+ ```yaml
+ litellm_settings:
+ require_auth_for_metrics_endpoint: true
+ ```
+ """
+
async def dispatch(self, request: Request, call_next):
# Check if this is a request to the metrics endpoint