LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corerunnablesbaseRunnablestream_events
    Method●Since v1.4

    stream_events

    Copy
    stream_events(
      self,
      input: Any,
      config: RunnableConfig | None = None,
      
    View source on GitHub
    *
    ,
    version
    :
    Literal
    [
    'v1'
    ,
    'v2'
    ,
    'v3'
    ]
    =
    'v2'
    ,
    include_names
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    include_types
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    include_tags
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    exclude_names
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    exclude_types
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    exclude_tags
    :
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    Iterator
    [
    StreamEvent
    ]
    |
    Iterator
    [
    Any
    ]

    Parameters

    NameTypeDescription
    input*Any

    The input to the Runnable.

    configRunnableConfig | None
    Default:None

    The config to use for the Runnable.

    versionLiteral['v1', 'v2', 'v3']
    Default:'v2'

    The version of the schema to use. 'v3' requires a subclass that implements the v3 streaming protocol. 'v1' and 'v2' are not supported on the sync path.

    include_namesSequence[str] | None
    Default:None
    include_typesSequence[str] | None
    Default:None
    include_tagsSequence[str] | None
    Default:None
    exclude_namesSequence[str] | None
    Default:None
    exclude_typesSequence[str] | None
    Default:None
    exclude_tagsSequence[str] | None
    Default:None
    **kwargsAny
    Default:{}

    Generate a stream of events synchronously.

    Synchronous counterpart to astream_events. For version='v3', subclasses that implement the v3 streaming protocol (BaseChatModel, CompiledGraph) override this method. All other versions and base-class calls raise NotImplementedError.

    Only include events from Runnable objects with matching names.

    Only include events from Runnable objects with matching types.

    Only include events from Runnable objects with matching tags.

    Exclude events from Runnable objects with matching names.

    Exclude events from Runnable objects with matching types.

    Exclude events from Runnable objects with matching tags.

    Additional keyword arguments to pass to the Runnable.