From 3a9fb724eb1d6e005d7fcf48c369e0076cfaf4d7 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:57:17 +0000 Subject: [PATCH] refactor(anthropic-adapter): use MidStreamFallbackError instead of importing openai Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com> --- .../experimental_pass_through/adapters/streaming_iterator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py index 2eaa19c0f0c..dbc4703b51b 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py @@ -16,11 +16,11 @@ from typing import ( get_args, ) -import openai from typing_extensions import assert_never from litellm._logging import verbose_logger from litellm._uuid import uuid +from litellm.exceptions import MidStreamFallbackError from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.types.llms.anthropic import ( AppliedEdit, @@ -40,7 +40,7 @@ _STREAMING_DELTA_TYPES = frozenset(get_args(StreamingContentBlockDeltaType)) def _error_status_and_message(exc: Exception) -> tuple[int, str]: - if isinstance(exc, (BaseLLMException, openai.APIStatusError)): + if isinstance(exc, (BaseLLMException, MidStreamFallbackError)): return exc.status_code, exc.message return 500, str(exc) or "Upstream stream ended before completion"