BerriAI/litellm · error · NotImplementedError
Use AsyncGoogleGenAIGenerateContentStreamingIterator for…
Error message
Use AsyncGoogleGenAIGenerateContentStreamingIterator for async iteration
What it means
The sync Google GenAI streaming iterator was consumed with __anext__/async-for; this sentinel NotImplementedError points the caller to AsyncGoogleGenAIGenerateContentStreamingIterator, since sync and async SSE iterators are separate classes here.
Solutions
- Use the AsyncGoogleGenAIGenerateContentStreamingIterator for async iteration over this stream.
- Use the synchronous iterator if you are in sync code.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/google_genai/streaming_iterator.py:149 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/63c9b66a863006c8.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/google_genai/streaming_iterator.py:149
def __iter__(self):
return self
def __next__(self):
try:
chunk: Final = _next_google_genai_sse_chunk(self.stream_iterator)
self.collected_chunks.append(chunk)
return chunk
except StopIteration:
raise StopIteration
def __aiter__(self):
return self
async def __anext__(self):
# This should not be used for sync responses
# If you need async iteration, use AsyncGoogleGenAIGenerateContentStreamingIterator
raise NotImplementedError("Use AsyncGoogleGenAIGenerateContentStreamingIterator for async iteration")
class AsyncGoogleGenAIGenerateContentStreamingIterator(BaseGoogleGenAIGenerateContentStreamingIterator):
"""
Async streaming iterator specifically for Google GenAI generate content API.
"""
def __init__(
self,
response,
model: str,
logging_obj: LiteLLMLoggingObj,
generate_content_provider_config: BaseGoogleGenAIGenerateContentConfig,
litellm_metadata: dict,
custom_llm_provider: str,
request_body: dict | None = None,
hidden_params: dict[str, Any] | None = None,
):View on GitHub (pinned to 77b7c6c40c)