From 5237fe4df3c8fc290e4f1f66cdeb18d047e26776 Mon Sep 17 00:00:00 2001 From: yassin Date: Tue, 15 Sep 2026 21:57:12 +0000 Subject: [PATCH] refactor(passthrough): read the deployment model_info request state in two steps Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/pass_through_endpoints/pass_through_endpoints.py | 3 ++- litellm/types/passthrough_endpoints/pass_through_endpoints.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 5d5275abad0..686544d352c 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -614,8 +614,9 @@ class HttpPassThroughEndpointHelpers(BasePassthroughUtils): _metadata.update( LiteLLMProxyRequestSetup.get_sanitized_user_information_from_key(user_api_key_dict=user_api_key_dict) ) + _request_state: Final = getattr(request, "state", None) deployment_model_info: Final = getattr( - getattr(request, "state", None), LITELLM_PASS_THROUGH_DEPLOYMENT_MODEL_INFO_STATE_KEY, None + _request_state, LITELLM_PASS_THROUGH_DEPLOYMENT_MODEL_INFO_STATE_KEY, None ) if isinstance(deployment_model_info, Mapping): _metadata["model_info"] = dict(deployment_model_info) diff --git a/litellm/types/passthrough_endpoints/pass_through_endpoints.py b/litellm/types/passthrough_endpoints/pass_through_endpoints.py index fb12daab199..e47acf9d68b 100644 --- a/litellm/types/passthrough_endpoints/pass_through_endpoints.py +++ b/litellm/types/passthrough_endpoints/pass_through_endpoints.py @@ -11,8 +11,7 @@ LITELLM_PASS_THROUGH_CUSTOM_BODY_STATE_KEY: Final = "litellm_pass_through_custom # exact byte/string body, such as AWS SigV4-signed requests. LITELLM_PASS_THROUGH_RAW_BODY_STATE_KEY: Final = "litellm_pass_through_raw_body" -# Request.state key carrying the `model_info` of the router deployment a provider -# route resolved (e.g. Vertex), so logging attributes the call to that deployment. +# `model_info` of the router deployment a provider route (e.g. Vertex) resolved for this request. LITELLM_PASS_THROUGH_DEPLOYMENT_MODEL_INFO_STATE_KEY: Final = "litellm_pass_through_deployment_model_info" # Attribute set on the FastAPI endpoint function of every user-defined pass-through