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]

fix: make policy_resolve_endpoints importable without FastAPI

Julio Quinteros Proe6385a6c836f
diff --git a/litellm/proxy/policy_engine/policy_resolve_endpoints.py b/litellm/proxy/policy_engine/policy_resolve_endpoints.py
index 318e990ff12..428ab2b63b2 100644
--- a/litellm/proxy/policy_engine/policy_resolve_endpoints.py
+++ b/litellm/proxy/policy_engine/policy_resolve_endpoints.py
@@ -6,8 +6,26 @@ Policy resolve and attachment impact estimation endpoints.
"""
import json
-
-from fastapi import APIRouter, Depends, HTTPException, Query
+from typing import TYPE_CHECKING
+
+# FastAPI imports - may not be available in all environments (e.g. during testing)
+try:
+ from fastapi import APIRouter, Depends, HTTPException, Query
+except ImportError:
+ # Provide stubs for type checking only
+ if TYPE_CHECKING:
+ from fastapi import APIRouter, Depends, HTTPException, Query
+ else:
+ # Create mock classes that won't be used
+ class APIRouter: # type: ignore[no-redef]
+ def post(self, *args, **kwargs):
+ def decorator(func):
+ return func
+ return decorator
+
+ def Depends(func): return func # type: ignore[misc]
+ HTTPException = Exception # type: ignore[misc,assignment]
+ def Query(*args, **kwargs): return None # type: ignore[misc]
from litellm._logging import verbose_proxy_logger
from litellm.constants import MAX_POLICY_ESTIMATE_IMPACT_ROWS