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: handle provider_config type error in passthrough error handler (#12101)

Cole McIntosha56c28ab2f85
diff --git a/litellm/passthrough/main.py b/litellm/passthrough/main.py
index a0d09ef7ce6..5e95b0a81bd 100644
--- a/litellm/passthrough/main.py
+++ b/litellm/passthrough/main.py
@@ -86,9 +86,39 @@ async def allm_passthrough_route(
response = init_response
return response
except Exception as e:
+ # For passthrough routes, we need to get the provider config to properly handle errors
+ from litellm.types.utils import LlmProviders
+ from litellm.utils import ProviderConfigManager
+
+ # Get the provider using the same logic as llm_passthrough_route
+ _, resolved_custom_llm_provider, _, _ = get_llm_provider(
+ model=model,
+ custom_llm_provider=custom_llm_provider,
+ api_base=api_base,
+ api_key=api_key,
+ )
+
+ # Get provider config if available
+ provider_config = None
+ if resolved_custom_llm_provider:
+ try:
+ provider_config = cast(
+ Optional["BasePassthroughConfig"], kwargs.get("provider_config")
+ ) or ProviderConfigManager.get_provider_passthrough_config(
+ provider=LlmProviders(resolved_custom_llm_provider),
+ model=model,
+ )
+ except Exception:
+ # If we can't get provider config, pass None
+ pass
+
+ if provider_config is None:
+ # If no provider config available, raise the original exception
+ raise e
+
raise base_llm_http_handler._handle_error(
e=e,
- provider_config=None,
+ provider_config=provider_config,
)