LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • 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
PythonlanggraphpregelmainPregelinvoke
Method●Since v0.6

invoke

Run the graph with a single input and config.

Copy
invoke(
  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,
  **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.
**kwargsAny
Default:{}

Additional keyword arguments to pass to the graph run.

View source on GitHub