Visitar URL original
Build checklist for the Graph API - Docs by LangChain
Skip to main content
This guide walks through the decisions you make when building a graph. For install and an end-to-end agent example, see the LangGraph quickstart. For a design walkthrough, see Thinking in the Graph API. For concepts, see the Graph API overview.

Build your graph

Work through these decisions in order. Each step includes a short example and links to the how-to for full recipes.
1

Define shared state

Decide what data nodes share and how updates merge.
  • Pick a schema (TypedDict, dataclass, or StateSchema in TypeScript).
  • Add a reducer for any key that multiple nodes write (for example, appending messages).
  • Use private or input/output schemas when the graph should hide internal channels from callers.
Here foo overwrites. bar concatenates.For schemas, reducers, messages, and private state, see Define and update state.
2

Choose control flow

Decide how work moves between nodes.
  • Sequence: Fixed steps in order.
  • Branch: Conditional edges pick the next node from state.
  • Parallel: Fan-out to several nodes, then fan-in (often with reducers).
  • Loop: Cycle until a termination condition, or cap runs with a recursion limit.
This sequence checks whether a number is even, then formats a message:
For branches, parallel paths, and loops, see Build sequences, branches, and loops.
3

Decide if you need Send or Command

Most graphs only need nodes, edges, and conditional edges. Keep routing in edges unless you hit one of the cases below. For patterns and examples, see Use Send and Command.Reach for the extras when the default model is not enough:
  • Use Send when you must run the same node once per item, each with its own input, and the item count is only known at runtime (map-reduce / orchestrator-worker).
  • Use Command when one step must both update state and choose the next node, resume after an interrupt, or update state from a tool.
4

Configure nodes as needed

Add runtime options when reliability or cost matters:
  • Retries and timeouts for flaky or slow steps
  • Error handlers and graph-wide node defaults
  • Caching for expensive repeated work
  • Runtime context or config for dependencies that do not belong in state
See Configure nodes.
5

Visualize the graph

Render a Mermaid or PNG diagram to review topology and debug routing.
See Visualize your graph.

Next steps