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 3aec95f5c02..ddb6e7b7021 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py @@ -388,6 +388,9 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): if chunk == "None" or chunk is None: raise Exception + if not chunk.choices and getattr(chunk, "usage", None) is None: + continue + should_start_new_block = self._should_start_new_content_block(chunk) if should_start_new_block: self._increment_content_block_index() @@ -609,6 +612,9 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): if chunk == "None" or chunk is None: raise Exception + if not chunk.choices and getattr(chunk, "usage", None) is None: + continue + # Check if we need to start a new content block should_start_new_block = self._should_start_new_content_block(chunk) if should_start_new_block: