{"record":{"id":"f016515a79895a4e","repo":"run-llama/llama_index","slug":"stream-call-is-not-supported-by-default","errorCode":null,"errorMessage":"stream_call is not supported by default.","messagePattern":"stream_call is not supported by default\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/types.py","lineNumber":127,"sourceCode":"\n    @property\n    @abstractmethod\n    def output_cls(self) -> Type[Model]:\n        pass\n\n    @abstractmethod\n    def __call__(self, *args: Any, **kwargs: Any) -> Union[Model, List[Model]]:\n        pass\n\n    async def acall(self, *args: Any, **kwargs: Any) -> Union[Model, List[Model]]:\n        return self(*args, **kwargs)\n\n    def stream_call(\n        self, *args: Any, **kwargs: Any\n    ) -> Generator[\n        Union[Model, List[Model], \"FlexibleModel\", List[\"FlexibleModel\"]], None, None\n    ]:\n        raise NotImplementedError(\"stream_call is not supported by default.\")\n\n    async def astream_call(\n        self, *args: Any, **kwargs: Any\n    ) -> AsyncGenerator[\n        Union[Model, List[Model], \"FlexibleModel\", List[\"FlexibleModel\"]], None\n    ]:\n        raise NotImplementedError(\"astream_call is not supported by default.\")\n\n\nclass PydanticProgramMode(str, Enum):\n    \"\"\"Pydantic program mode.\"\"\"\n\n    DEFAULT = \"default\"\n    OPENAI = \"openai\"\n    LLM = \"llm\"\n    FUNCTION = \"function\"\n    GUIDANCE = \"guidance\"\n    LM_FORMAT_ENFORCER = \"lm-format-enforcer\"","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/types.py#L109-L145","documentation":"PydanticProgram (the base class for structured-output programs) implements __call__ and acall, but streaming a structured program is not generically possible, so the default stream_call() raises NotImplementedError. Only specific subclasses (e.g. OpenAIPydanticProgram with streaming support) override it.","triggerScenarios":"Calling program.stream_call(...) on a pydantic program that does not override stream_call - typical with LLMTextCompletionProgram, GuidanceProgram, or function-calling programs used through generic code that prefers streaming when available.","commonSituations":"Writing UI code that tries stream_call first and falls back to __call__; switching a working non-streaming program to streaming without checking the subclass supports it.","solutions":["Use the non-streaming API: output = program(input=..., description=...).","Switch to a subclass that supports streaming (e.g. OpenAIPydanticProgram) if you truly need incremental structured output.","Feature-detect before calling: hasattr check / isinstance check against streaming-capable subclasses."],"exampleFix":"# before\n chunks = list(program.stream_call(input='extract...'))  # NotImplementedError\n\n# after\n result = program(input='extract...')  # non-streaming\n # or use a streaming-capable subclass:\n # from llama_index.core.program import OpenAIPydanticProgram","handlingStrategy":"fallback","validationCode":"def supports_streaming(program) -> bool:\n    # only subclasses that override stream_call can stream\n    return type(program).stream_call is not PydanticProgram.stream_call","typeGuard":"from llama_index.core.program import PydanticProgram\n\ndef is_streamable_program(program) -> bool:\n    return type(program).stream_call is not PydanticProgram.stream_call","tryCatchPattern":"try:\n    chunks = list(program.stream_call(input=...))\nexcept NotImplementedError:\n    result = program(input=...)  # graceful fallback to sync call\nelse:\n    result = merge(chunks)","preventionTips":["Feature-detect streaming support before calling stream_call.","Design call sites with a non-streaming fallback path.","Pin and test the exact program subclass you rely on for streaming."],"tags":["pydantic-program","streaming","not-implemented"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}