LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Graphs
    • Functional API
    • Pregel
    • Checkpointing
    • Storage
    • Caching
    • Types
    • Runtime
    • Config
    • Errors
    • Constants
    • Channels
    • Agents
    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    PythonlanggraphpregelmainPregelstream_events
    Method●Since v1.2

    stream_events

    Copy
    stream_events(
      self,
      input: InputT | Command | None,
      config: RunnableConfig 
    View source on GitHub
    |
    None
    =
    None
    ,
    *
    ,
    version
    :
    Literal
    [
    'v1'
    ,
    'v2'
    ,
    'v3'
    ]
    =
    'v2'
    ,
    interrupt_before
    :
    All
    |
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    interrupt_after
    :
    All
    |
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    control
    :
    RunControl
    |
    None
    =
    None
    ,
    transformers
    :
    Sequence
    [
    Callable
    [
    [
    tuple
    [
    str
    ,
    .
    .
    .
    ]
    ]
    ,
    Any
    ]
    ]
    |
    None
    =
    None
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    Any

    Parameters

    NameTypeDescription
    input*InputT | Command | None

    Graph input.

    configRunnableConfig | None
    Default:None

    Optional runnable config.

    versionLiteral['v1', 'v2', 'v3']
    Default:'v2'
    interrupt_beforeAll | Sequence[str] | None
    Default:None
    interrupt_afterAll | Sequence[str] | None
    Default:None
    controlRunControl | None
    Default:None
    transformersSequence[Callable[[tuple[str, ...]], Any]] | None
    Default:None
    **kwargsAny
    Default:{}

    Stream events from this graph.

    For version="v1" / "v2", yields StreamEvent dicts (see Runnable.stream_events). For version="v3", returns a GraphRunStream whose typed projections the caller drives by iterating — no background thread.

    Warning

    The version="v3" API is experimental and may change.

    Builds a StreamMux from the built-in transformers, this graph's compile-time stream_transformers, and any additional transformers= supplied at the call site. run.output, run.interrupted, and run.interrupts work regardless of which transformers are registered.

    Note:

    Nesting v1 stream(stream_mode="messages") inside a node of a stream_events(version="v3") run is not fully supported. The outer v3 messages handler reroutes BaseChatModel.invoke through the v2 event protocol, so the inner v1 handler does not see on_llm_new_token chunks. The inner stream still yields a finalized message via on_llm_end. Use stream_events(version="v3") for the inner graph as well, or call chat_model.stream(...) explicitly, to get token-level streaming.

    Streaming-event schema version. "v3" selects the content-block-centric streaming protocol.

    Nodes to interrupt before, if any. Only used for version="v3".

    Nodes to interrupt after, if any. Only used for version="v3".

    Optional run control used to request cooperative drain. Only used for version="v3".

    Extra transformer classes or configured factories appended after compile-time stream_transformers. Factories are called as factory(scope) so they can propagate to subgraph scopes. Only used for version="v3".

    For version="v1"/"v2", forwarded to Runnable.stream_events. For version="v3", forwarded to the underlying stream(...) call (e.g. context, durability, output_keys, print_mode, debug). stream_mode and subgraphs are not accepted under version="v3" and raise TypeError if supplied; v3 owns them.