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]

feat(pass_through_endpoints.py): raise 404 if passthrough endpoint has been deleted by the user

Krrish Dholakiab4fc7d3cfad0
diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
index 5f3a49f307a..8542f87327f 100644
--- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
+++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
@@ -974,6 +974,11 @@ def create_pass_through_route(
] = None, # if pass-through endpoint is a streaming request
subpath: str = "", # captures sub-paths when include_subpath=True
):
+
+ from litellm.proxy.pass_through_endpoints.pass_through_endpoints import (
+ InitPassThroughEndpointHelpers,
+ )
+
# Construct the full target URL with subpath if needed
full_target = (
HttpPassThroughEndpointHelpers.construct_target_url_with_subpath(
@@ -981,6 +986,14 @@ def create_pass_through_route(
)
)
+ if not InitPassThroughEndpointHelpers.is_registered_pass_through_route(
+ route=endpoint
+ ):
+ raise HTTPException(
+ status_code=404,
+ detail=f"Pass-through endpoint {target} not found. This could have been deleted or not yet added to the proxy.",
+ )
+
return await pass_through_request( # type: ignore
request=request,
target=full_target,