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 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 CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    PythonlanggraphpregelmainPregelainvoke
    Methodā—Since v0.6

    ainvoke

    Asynchronously run the graph with a single input and config.

    Copy
    ainvoke(
      self,
      input: InputT | Command | None,
      config: RunnableConfig | None = None,
      *,
      context: ContextT | None = None,
      stream_mode: StreamMode = 'values',
      print_mode: StreamMode | Sequence[StreamMode] = (),
      output_keys: str | Sequence[str] | None = None,
      interrupt_before: All | Sequence[str] | None = None,
      interrupt_after: All | Sequence[str] | None = None,
      durability: Durability | None = None,
      version: Literal['v1', 'v2'] = 'v1',
      **kwargs: Any = {}
    ) -> dict[str, Any] | Any

    Parameters

    NameTypeDescription
    input*InputT | Command | None

    The input data for the graph. It can be a dictionary or any other type.

    configRunnableConfig | None
    Default:None

    The configuration for the graph run.

    contextContextT | None
    Default:None

    The static context to use for the run.

    stream_modeStreamMode
    Default:'values'

    The stream mode for the graph run.

    print_modeStreamMode | Sequence[StreamMode]
    Default:()

    Accepts the same values as stream_mode, but only prints the output to the console, for debugging purposes.

    Does not affect the output of the graph in any way.

    output_keysstr | Sequence[str] | None
    Default:None

    The output keys to retrieve from the graph run.

    interrupt_beforeAll | Sequence[str] | None
    Default:None

    The nodes to interrupt the graph run before.

    interrupt_afterAll | Sequence[str] | None
    Default:None

    The nodes to interrupt the graph run after.

    durabilityDurability | None
    Default:None

    The durability mode for the graph execution, defaults to "async".

    Options are:

    • "sync": Changes are persisted synchronously before the next step starts.
    • "async": Changes are persisted asynchronously while the next step executes.
    • "exit": Changes are persisted only when the graph exits.
    versionLiteral['v1', 'v2']
    Default:'v1'

    The streaming format version. "v1" (default) returns the traditional format, "v2" returns StreamPart typed dicts when stream_mode is not "values".

    **kwargsAny
    Default:{}

    Additional keyword arguments to pass to the graph run.

    View source on GitHub