{"record":{"id":"63c9b66a863006c8","repo":"BerriAI/litellm","slug":"use-asyncgooglegenaigeneratecontentstreamingiterat","errorCode":null,"errorMessage":"Use AsyncGoogleGenAIGenerateContentStreamingIterator for async iteration","messagePattern":"Use AsyncGoogleGenAIGenerateContentStreamingIterator for async iteration","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"litellm/google_genai/streaming_iterator.py","lineNumber":149,"sourceCode":"\n    def __iter__(self):\n        return self\n\n    def __next__(self):\n        try:\n            chunk: Final = _next_google_genai_sse_chunk(self.stream_iterator)\n            self.collected_chunks.append(chunk)\n            return chunk\n        except StopIteration:\n            raise StopIteration\n\n    def __aiter__(self):\n        return self\n\n    async def __anext__(self):\n        # This should not be used for sync responses\n        # If you need async iteration, use AsyncGoogleGenAIGenerateContentStreamingIterator\n        raise NotImplementedError(\"Use AsyncGoogleGenAIGenerateContentStreamingIterator for async iteration\")\n\n\nclass AsyncGoogleGenAIGenerateContentStreamingIterator(BaseGoogleGenAIGenerateContentStreamingIterator):\n    \"\"\"\n    Async streaming iterator specifically for Google GenAI generate content API.\n    \"\"\"\n\n    def __init__(\n        self,\n        response,\n        model: str,\n        logging_obj: LiteLLMLoggingObj,\n        generate_content_provider_config: BaseGoogleGenAIGenerateContentConfig,\n        litellm_metadata: dict,\n        custom_llm_provider: str,\n        request_body: dict | None = None,\n        hidden_params: dict[str, Any] | None = None,\n    ):","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/google_genai/streaming_iterator.py#L131-L167","documentation":"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.","triggerScenarios":"Thrown at litellm/google_genai/streaming_iterator.py:149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the AsyncGoogleGenAIGenerateContentStreamingIterator for async iteration over this stream.","Use the synchronous iterator if you are in sync code."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}