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]

refactor: define pass-through custom body state key in types module

shivam3742b0cee1ec
diff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
index 6e354290fe4..1ef866486ec 100644
--- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
+++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
@@ -37,11 +37,13 @@ from litellm.proxy.common_utils.http_parsing_utils import (
from litellm.proxy.pass_through_endpoints.common_utils import get_litellm_virtual_key
from litellm.proxy.pass_through_endpoints.pass_through_endpoints import (
HttpPassThroughEndpointHelpers,
- LITELLM_PASS_THROUGH_CUSTOM_BODY_STATE_KEY,
create_pass_through_route,
create_websocket_passthrough_route,
websocket_passthrough_request,
)
+from litellm.types.passthrough_endpoints.pass_through_endpoints import (
+ LITELLM_PASS_THROUGH_CUSTOM_BODY_STATE_KEY,
+)
from litellm.proxy.utils import is_known_model
from litellm.proxy.vector_store_endpoints.utils import (
is_allowed_to_call_vector_store_endpoint,
diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
index 40193def8d2..d582240395f 100644
--- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
+++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
@@ -61,6 +61,7 @@ from litellm.secret_managers.main import get_secret_str
from litellm.types.llms.custom_http import httpxSpecialProvider
from litellm.types.passthrough_endpoints.pass_through_endpoints import (
EndpointType,
+ LITELLM_PASS_THROUGH_CUSTOM_BODY_STATE_KEY,
PassthroughStandardLoggingPayload,
)
@@ -76,11 +77,6 @@ _registered_pass_through_routes: Dict[
str, Dict[str, Union[str, List[str], Dict[str, Any]]]
] = {}
-# Programmatic pass-through callers (e.g. Bedrock proxy) attach JSON here. Must not use a
-# `custom_body: dict` route parameter — FastAPI would treat it as the HTTP body and reject
-# multipart/form-data before the handler runs.
-LITELLM_PASS_THROUGH_CUSTOM_BODY_STATE_KEY = "litellm_pass_through_custom_body"
-
def get_response_body(response: httpx.Response) -> Optional[dict]:
try:
diff --git a/litellm/types/passthrough_endpoints/pass_through_endpoints.py b/litellm/types/passthrough_endpoints/pass_through_endpoints.py
index c99775f2a6c..4a07fa5e849 100644
--- a/litellm/types/passthrough_endpoints/pass_through_endpoints.py
+++ b/litellm/types/passthrough_endpoints/pass_through_endpoints.py
@@ -3,6 +3,10 @@ from typing import Optional
from typing_extensions import TypedDict
+# Request.state key for programmatic pass-through callers (e.g. Bedrock proxy) that attach
+# JSON without a FastAPI `custom_body` parameter (which would consume the HTTP body).
+LITELLM_PASS_THROUGH_CUSTOM_BODY_STATE_KEY = "litellm_pass_through_custom_body"
+
class EndpointType(str, Enum):
VERTEX_AI = "vertex-ai"