Comparison · Updated 2026-06-21
LangChain vs LangGraph
Two libraries from the same team, sharing a model layer, sitting on different rungs of the LLM application stack. LangChain is the general-purpose toolkit: chains, prompts, retrievers, document loaders, vector store wrappers, model abstractions, and the widest tool ecosystem in the Python LLM space. LangGraph is the official orchestration layer on top: explicit state, typed nodes, conditional edges, persistence checkpoints, and time-travel debugging. The honest framing is not "either/or" but "which layer is the right primary abstraction for the workload" -- and most production setups use both, with LangChain primitives inside LangGraph nodes. This is the side-by-side.
LangChain
General LLM application toolkit. Chains, prompts, retrievers, agents, document loaders -- the broadest Python LLM toolkit and the largest tool ecosystem.
See alternatives →LangGraph
State-graph orchestration framework. Nodes, edges, persistent state, and time-travel debugging -- the production-leaning multi-agent abstraction from LangChain Inc.
See alternatives →The short answer
- Winner for general LLM applications and RAG: LangChain. Retrievers, loaders, and chains are first-class.
- Winner for stateful multi-step agent backends: LangGraph. Explicit state, persistence, branching.
- Winner for token efficiency on multi-step workloads: LangGraph. Tight per-node context control.
- Winner for first-hour ramp: LangChain. Wider toolkit, no graph to design.
- Best for: LangChain for primitives; LangGraph for orchestration; use both together in production.
Snapshot comparison
Before the section-by-section breakdown, the one-screen version.
| Dimension | LangChain | LangGraph |
|---|---|---|
| Primary shape | General LLM toolkit | State-graph orchestration |
| Audience | Any Python developer doing LLM work | Production agent engineers |
| License | MIT | MIT |
| Maintainer | LangChain Inc. | LangChain Inc. |
| Model coverage | Every provider, deep wrappers | Every provider via LangChain |
| Built-in RAG primitives | Loaders, splitters, retrievers | Reuse LangChain |
| State model | Implicit (chain memory) | Explicit, typed |
| Determinism | Loose | Deterministic transitions |
| Persistence / checkpoints | Memory adapters | First-class |
| Human-in-the-loop | Manual wiring | Interrupt + resume native |
| Observability | LangSmith integration | LangSmith integration |
| Learning curve | Lower up front | Higher up front, payoff later |
| Best for | Any LLM workload, RAG-first | Production stateful agents |
Two different mental models
The right tool depends on which of these reads like your problem.
LangChain thinks "toolkit for any LLM workload". You import what you need: a loader for PDFs, a splitter for chunking, an embedding model, a vector store wrapper, a retriever, a prompt template, a chain. Composition is the unit of work.
LangGraph thinks "state graph". You declare a typed state object, a set of nodes that read and write state, and conditional edges that decide what runs next. Every transition is named, every state mutation is logged, and the same input produces the same path.
If your problem is "RAG over docs, summarisation, classification, or a chain of LLM calls", that is LangChain shaped. If your problem is "planner + executor + critic looping with persistence and human approvals", that is LangGraph shaped.
Use cases -- when each one wins
LangChain fits when
- RAG over documents. Loaders, splitters, embeddings, retrievers -- native.
- Single-step chains. Prompt + model + parser, with no need for state.
- Provider portability. Swap models and stores with one-line changes.
- Quick prototypes. Demo to working chain in an hour after the quickstart.
- The widest tool ecosystem. If an integration exists, LangChain has it.
LangGraph fits when
- Production agent backends. Determinism, persistence, and observability matter.
- Long-running workflows with HITL pauses. Pause, await human input, resume from checkpoint.
- Branching logic with conditions. Edges fire on state predicates.
- Multi-step retrieval and reasoning. RAG combined with planner / executor inside one graph.
- Migrating from ad-hoc LangChain chains. When the chain became a maze.
Learning curve
LangChain has a wide surface and a gentle entry. Quickstart to working chain in an hour. The challenge is the ecosystem size -- every problem has three valid solutions.
LangGraph has higher up-front cost, lower long-term cost. You need to think about state schema and edges before writing the first node. Most engineers need a day or two to internalise the mental model. Once it lands, you ship reliably and scale without surprises.
Practical rule: learn LangChain first to understand the primitives, then graduate to LangGraph when the work needs durable state.
Pricing comparison
Both projects are open source. The real cost is model inference.
| Cost line | LangChain | LangGraph |
|---|---|---|
| Framework licence | Free (MIT) | Free (MIT) |
| Self-hosting | Any Python host | Any Python host |
| Model inference | Pay-per-token (any provider) | Pay-per-token (any provider) |
| Hosted runtime | LangSmith (paid) | LangGraph Platform (paid) |
| Observability | LangSmith (free tier + paid) | LangSmith (free tier + paid) |
| Persistence layer | Memory adapters | Built-in (BYO store) |
| Typical multi-step workflow (per 1k tasks) | ~$10-50 on GPT-4o-mini | ~$8-35 on GPT-4o-mini |
| Hidden costs | Ecosystem churn | Up-front design work |
The pattern: licence cost is zero. Model inference dominates. LangGraph is meaningfully cheaper per task on multi-step workloads because state is explicit. LangChain chains accumulate context as they grow.
Final verdict
These two are layered, not competing. The right call comes down to two questions: does the workload need durable state, and how many steps does it have?
- Single-step LLM applications and RAG: LangChain wins. The toolkit is mature and the retrievers are first-class.
- Multi-step stateful agent backends: LangGraph wins. Explicit state and checkpoints are the right primitives.
- Both at once: the production default. LangGraph on top for orchestration; LangChain underneath for retrievers, tool wrappers, and model abstractions.
Meta-recommendation: many teams stretch ad-hoc LangChain chains far past their breaking point before adopting LangGraph -- and pay the rewrite cost twice. Reach for LangGraph the moment the workload becomes stateful. The wider landscape is in the AI Agent Frameworks pillar; the deeper shortlists are best LangChain alternatives and best LangGraph alternatives.
Related guides
Related alternatives
Next read
FAQ
- LangChain vs LangGraph -- which one should I pick?
- If you are building general LLM applications -- RAG, chains, single-agent tools, retrievers -- pick LangChain. If you are building a stateful multi-step agent backend with explicit state, persistence, and branching, pick LangGraph. They are from the same team and compose: LangChain primitives inside LangGraph nodes is the production default.
- Is LangGraph built on top of LangChain?
- Yes -- LangGraph is the official orchestration layer from LangChain Inc. LangGraph reuses LangChain models, tools, and retrievers as building blocks. The split is: LangChain owns the primitives; LangGraph owns the graph runtime, persistence, and human-in-the-loop interrupts.
- Is LangGraph easier to learn than LangChain?
- For single-step LLM workflows, LangChain is lighter -- you do not need a graph. For multi-step stateful workflows, LangGraph is sharper because state, nodes, and edges replace ad-hoc chains. Most engineers learn LangChain first, then graduate to LangGraph when the workflow gets stateful.
- How do token costs compare?
- Both call the same models. LangGraph state is explicit -- you pass exactly the state slice each node needs, which keeps prompts tight. Ad-hoc LangChain chains tend to grow accidentally as you bolt on more steps. For equivalent multi-step workloads, LangGraph typically costs 20-40% less because context is controlled per node.
- Can I use LangChain and LangGraph together?
- Yes -- this is the recommended pattern. LangGraph nodes call LangChain chains, retrievers, and tools. The artifact is a LangGraph that uses LangChain primitives under the hood. Most production LangGraph apps look exactly like this.
- Are LangChain and LangGraph open source?
- Yes -- both are MIT-licensed and maintained by LangChain Inc. Paid offerings (LangSmith for observability, LangGraph Platform for managed execution) sit alongside the open-source libraries.
- Which one wins for RAG workloads?
- LangChain -- when the workload is a single-step RAG chain. LangGraph wins when RAG is one step in a longer stateful agent loop with planning, tool use, or human approvals.
- When does LangGraph beat LangChain outright?
- When the workload is multi-step stateful: planner agent, tool-using executor, critic, human-in-the-loop pauses, retries from a checkpoint. LangGraph makes state and transitions first-class. Plain LangChain chains hit ceilings as soon as you need durable state and conditional branching.