{"record":{"id":"e5ab0c4a398e0ace","repo":"BerriAI/litellm","slug":"an-unknown-error-occurred-with-the-stream","errorCode":null,"errorMessage":"An unknown error occurred with the stream","messagePattern":"An unknown error occurred with the stream","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/streaming_handler.py","lineNumber":1288,"sourceCode":"        elif (\n            self.custom_llm_provider and self.custom_llm_provider == \"aleph_alpha\"\n        ):  # aleph alpha doesn't provide streaming\n            response_obj = self.handle_aleph_alpha_chunk(chunk)\n            completion_obj[\"content\"] = response_obj[\"text\"]\n            if response_obj[\"is_finished\"]:\n                self.received_finish_reason = response_obj[\"finish_reason\"]\n        elif self.custom_llm_provider == \"nlp_cloud\":\n            try:\n                response_obj = self.handle_nlp_cloud_chunk(chunk)\n                completion_obj[\"content\"] = response_obj[\"text\"]\n                if response_obj[\"is_finished\"]:\n                    self.received_finish_reason = response_obj[\"finish_reason\"]\n            except Exception as e:\n                if self.received_finish_reason:\n                    raise e\n                else:\n                    if self.sent_first_chunk is False:\n                        raise Exception(\"An unknown error occurred with the stream\")\n                    self.received_finish_reason = \"stop\"\n        elif self.custom_llm_provider == \"vertex_ai\" and not isinstance(chunk, ModelResponseStream):\n            vertex_chunk: Final = cast(_VertexChunkLike, chunk)\n            import proto\n\n            if hasattr(vertex_chunk, \"candidates\") is True:\n                try:\n                    try:\n                        completion_obj[\"content\"] = vertex_chunk.text\n                    except Exception as e:\n                        original_exception: Final = e\n                        if \"Part has no text.\" in str(e):\n                            ## check for function calling\n                            function_call: Final = vertex_chunk.candidates[0].content.parts[0].function_call\n\n                            args_dict: Final = {}\n\n                            # Check if it's a RepeatedComposite instance","sourceCodeStart":1270,"sourceCodeEnd":1306,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/streaming_handler.py#L1270-L1306","documentation":"Streaming chunk-parser fallback: when chunk parsing for a provider (e.g. nlp_cloud) fails with an exception not matching known cases, a generic 'unknown stream error' is raised — the chunk was not convertible into a completion object and no more specific diagnosis exists.","triggerScenarios":"Thrown at litellm/litellm_core_utils/streaming_handler.py:1288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the streaming request and enable verbose logging to capture the underlying error.","Check provider status and network stability."],"exampleFix":null,"handlingStrategy":"try-catch","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"}