{"record":{"id":"a66e34e5848a429f","repo":"langchain-ai/langchain","slug":"stream-events-version-version-r-is-not-supporte","errorCode":null,"errorMessage":"stream_events(version={version!r}) is not supported. Use astream_events() for v1/v2, or stream_events(version='v3') on a supported subclass.","messagePattern":"stream_events\\(version=(.+?)\\) is not supported\\. Use astream_events\\(\\) for v1/v2, or stream_events\\(version='v3'\\) on a supported subclass\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/runnables/base.py","lineNumber":1746,"sourceCode":"\n        \"\"\"\n        # Base impl always raises; consume args so they don't trip ARG002.\n        del input, config, include_names, include_types, include_tags\n        del exclude_names, exclude_types, exclude_tags, kwargs\n        if version == \"v3\":\n            msg = (\n                \"stream_events(version='v3') is only supported on Runnable subclasses \"\n                \"that implement the v3 streaming protocol \"\n                \"(BaseChatModel, CompiledGraph). \"\n                f\"Got: {type(self).__name__}\"\n            )\n            raise NotImplementedError(msg)\n        msg = (\n            f\"stream_events(version={version!r}) is not supported. \"\n            \"Use astream_events() for v1/v2, or stream_events(version='v3') \"\n            \"on a supported subclass.\"\n        )\n        raise NotImplementedError(msg)\n\n    def transform(\n        self,\n        input: Iterator[Input],\n        config: RunnableConfig | None = None,\n        **kwargs: Any | None,\n    ) -> Iterator[Output]:\n        \"\"\"Transform inputs to outputs.\n\n        Default implementation of transform, which buffers input and calls `astream`.\n\n        Subclasses must override this method if they can start producing output while\n        input is still being generated.\n\n        Args:\n            input: An iterator of inputs to the `Runnable`.\n            config: The config to use for the `Runnable`.\n            **kwargs: Additional keyword arguments to pass to the `Runnable`.","sourceCodeStart":1728,"sourceCodeEnd":1764,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/runnables/base.py#L1728-L1764","documentation":"Raised by the base `Runnable.stream_events` when `version` is 'v1' or 'v2' (or anything unrecognized besides the v3 branch). The synchronous `stream_events` API only implements v3; v1/v2 event streaming exists solely in the async `astream_events` path. The message states this directly: use `astream_events()` for v1/v2, or `stream_events(version='v3')` on a supported subclass.","triggerScenarios":"`chain.stream_events(inp, version=\"v2\")` — mirroring the familiar `astream_events(version=\"v2\")` default — or `version=\"v1\"`. Any non-'v3' value reaches the second raise in the base implementation.","commonSituations":"Copy-pasting async streaming code and only dropping the leading `a`; assuming parity between sync and async event APIs; defaults carried over from `astream_events` call sites where v2 is standard.","solutions":["Switch to the async API: `async for ev in chain.astream_events(inp, version=\"v2\")`","If code must stay synchronous, use `stream_events(inp, version=\"v3\")` on a BaseChatModel/CompiledGraph (a non-v3 subclass will raise the companion v3 error)","If no event granularity is needed, use plain `chain.stream(inp)` / `chain.invoke(inp)` instead"],"exampleFix":"# before\nfor ev in chain.stream_events(inp, version=\"v2\"):\n    ...  # NotImplementedError: not supported\n\n# after\nasync def run():\n    async for ev in chain.astream_events(inp, version=\"v2\"):\n        ...","handlingStrategy":"validation","validationCode":"def checked_sync_version(v: str) -> Literal[\"v3\"]:\n    if v != \"v3\":\n        msg = \"sync stream_events supports only version='v3'; use astream_events for v1/v2\"\n        raise ValueError(msg)\n    return \"v3\"","typeGuard":"def is_sync_stream_version(v: object) -> bool:\n    return v == \"v3\"","tryCatchPattern":"try:\n    for ev in chain.stream_events(inp, version=version):\n        ...\nexcept NotImplementedError as e:\n    if \"astream_events\" in str(e):\n        # route to the async API instead\n        raise RuntimeError(\"use astream_events(version='v1'|'v2')\") from e\n    raise","preventionTips":["Remember sync stream_events is v3-only; v1/v2 are async-only APIs","Use chain.stream()/invoke() when event metadata is unnecessary","Standardize on the async event API in new code"],"tags":["runnables","streaming","stream-events","notimplementederror","async"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}