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: add handling for user-disabled mid-stream fallbacks

rohan.w.charlese70b1bbfadaa
diff --git a/litellm/router.py b/litellm/router.py
index 638df49ac05..9e12fbe9433 100644
--- a/litellm/router.py
+++ b/litellm/router.py
@@ -1380,6 +1380,11 @@ class Router:
Catches errors for fallbacks using the router's fallback system
"""
+ if initial_kwargs.get("disable_fallbacks", False):
+ verbose_router_logger.info("Mid stream fallback disabled by user, re-raising original error")
+ if e.original_exception is not None:
+ raise e.original_exception
+ raise e
from litellm.exceptions import MidStreamFallbackError
class FallbackStreamWrapper(CustomStreamWrapper):