Pydantic AI vs LangChain vs LangGraph: how they differ and which to use
LangChain agents run on LangGraph, so the choice is a typed agent loop (Pydantic AI), a minimal agent harness you extend (LangChain) or a graph you write (LangGraph).
Pydantic AI, LangChain and LangGraph are not three equal rivals. LangChain’s agents are built on LangGraph, so LangChain vs LangGraph is a choice of layer. Pydantic AI is the separate one: a Python framework from the Pydantic team that is typed end to end. Pick Pydantic AI when typed inputs and outputs drive the design, LangChain’s create_agent when you want a ready agent you extend with middleware, and LangGraph when you want to write the control flow as a graph yourself.
Each has its own page: Pydantic AI, LangChain and LangGraph. Below, the same criteria side by side, from each project’s own docs.
How the layers fit
LangChain create_agent + middleware
|
v built on
LangGraph state, nodes, edges, checkpoints
Pydantic AI Agent + tools + output type
|
v optional
Pydantic Graph, Evals, durable engines
LangGraph’s docs say higher-level options such as LangChain agents sit on top of it. The LangChain docs call create_agent “a minimal, highly configurable harness” that you extend with middleware for things like guardrails and retries. Pydantic AI keeps one typed agent loop at the center and offers Pydantic Graph for cases where “one agent loop is not enough”.
Side by side
| Pydantic AI | LangChain | LangGraph | |
|---|---|---|---|
| Core idea | Typed agent: model, tools, output type, dependencies (overview) | An agent harness: create_agent with a model, tools, prompt and middleware (overview) |
Graph of nodes and edges over shared state (overview) |
| Level | Agent framework, with a graph package for harder flows | Higher-level agent API | Low-level; does not prescribe prompts or agent architecture |
| Who writes control flow | The agent loop runs it; Pydantic Graph if you want it explicit | The agent loop runs it; middleware changes behavior | You, as nodes and edges; fixed code steps and LLM steps can mix |
| Structured output | Tool arguments and final answers validated against your types by default (overview) | response_format with provider-native or tool-based strategies; Pydantic models return validated instances (docs) |
Whatever your nodes do; the LangChain layer provides the above |
| Models | Swap with a string; “virtually every model and provider” (overview) | One interface over OpenAI, Anthropic, Google, Ollama, AWS Bedrock and others (overview) | Any model you call inside a node; LangChain models plug in |
| Long-running work | Durable execution through nine engines, including Temporal, DBOS and Prefect, one per agent (durable execution) | Through LangGraph | Built-in checkpointing: “Checkpoint state and resume after failures or pauses” (overview) |
| Human approval | Tool approval is built in (overview) | HumanInTheLoopMiddleware per tool; needs a checkpointer (docs) |
“Pause execution, inspect or edit state, then continue” (overview) |
| MCP | MCP capability is the recommended route (MCP docs) |
MCPAdapter, a beta namespace needing langchain[mcp]>=1.4.0 (docs) |
Through LangChain’s adapter |
| Evals | Pydantic Evals grades outputs and tool-call trajectories on datasets or live traffic (overview) | The agentevals package scores agent trajectories against a reference or with an LLM judge (evals docs) |
agentevals also has graph trajectory evaluators that score the nodes visited (README) |
| Tracing | OpenTelemetry-native; any OpenTelemetry backend works (overview) | Traced through instrumentors such as OpenInference’s (example) | The same LangChain instrumentor traces graphs (example) |
| Python | 3.11 or later, MIT (PyPI) | 3.10 or later, MIT (PyPI) | 3.10 or later, MIT (PyPI) |
| Install | pip install pydantic-ai (overview) |
pip install langchain (PyPI) |
pip install -U langgraph (overview) |
For what MCP is, see Model Context Protocol.
Pydantic AI vs LangChain
Both give you a working agent in a few lines and both validate structured output. The difference is where the types sit.
In Pydantic AI, types are the organizing idea: an output_type, a deps_type for injected dependencies, and tools whose signatures become schemas. A failed validation prompts the model to retry (overview). LangChain’s agent is a smaller harness that you shape with middleware and a response_format; it validates Pydantic outputs and feeds schema errors back to the model under its tool strategy (structured output).
Two other differences matter in practice. LangChain 1.0 moved legacy chains and retrievers into a separate langchain-classic package (migration guide), so old tutorials may import things that moved. Pydantic AI had its own breaking 2.0 release, covered on its framework page. Check the version a tutorial targets in either case.
| If you need | Lean toward |
|---|---|
| Typed output and typed dependencies as the core design | Pydantic AI |
| A ready agent with middleware for guardrails, retries and routing | LangChain |
| One model interface across many providers | Either; both document it |
| Evals on live production traffic as well as datasets | Pydantic AI (Pydantic Evals) |
| Python 3.10 support | LangChain; Pydantic AI needs 3.11 |
Pydantic AI vs LangGraph
This is a comparison of an agent loop with a graph. Pydantic AI runs the loop and lets you add Pydantic Graph when you need typed control flow. LangGraph starts from the graph: you define nodes, edges and state, and the docs say it does not prescribe prompts or agent architecture.
Durability differs in shape. LangGraph checkpoints state itself. Pydantic AI hands durability to an engine such as Temporal, which journals model requests and tool calls and replays completed ones after a crash; saving and forking runs is a separate feature in its harness package.
| If you need | Lean toward |
|---|---|
| Loops, branches and parallel paths you design node by node | LangGraph |
| One agent with typed tools and output, little orchestration | Pydantic AI |
| Checkpoints built into the core package | LangGraph |
| Run agents on an engine your team already operates (Temporal, DBOS, Prefect) | Pydantic AI |
LangChain vs LangGraph
Use LangChain when one agent with tools is enough. Use LangGraph when you need to write the flow. They are not exclusive: LangChain’s docs list a custom workflow built with LangGraph as one multi-agent pattern, “mixing deterministic logic and agentic behavior”. Human approval shows the layering: LangChain’s middleware needs a checkpointer, which comes from the LangGraph layer (docs).
Which to choose
| Your situation | Start with |
|---|---|
| One agent, typed results, and the types are the point | Pydantic AI |
| One agent, fast start, extend with middleware | LangChain create_agent |
| A multi-step workflow with branches, loops and pauses | LangGraph |
| Existing LangChain code that needs a custom flow | Add LangGraph in the same app |
| Long runs that must survive deploys on Temporal or DBOS | Pydantic AI, or LangGraph checkpoints |
| A plain function could do the job | None of them |
This table is a judgement from the docs, not a benchmark. The docs describe features, not how each performs on your task, so test on your own data. See LLM evaluation and testing AI agents. For ideas behind the criteria, see agent orchestration, human-in-the-loop AI and multi-agent systems. Other options: OpenAI Agents SDK, CrewAI and LangGraph vs CrewAI vs AutoGen.
Tracing any of the three
Whichever you pick, agent runs are hard to debug without traces of each model call and tool call. For the method, see agent tracing and LLM observability. HoneyHive documents integrations for all three: Pydantic AI, LangChain and LangGraph. The LangChain page says the same instrumentor also traces LangGraph graphs.
FAQ
Is LangChain built on LangGraph?
Yes, for agents. The LangChain docs say its agents are built on LangGraph, which supplies durable execution, human-in-the-loop support and persistence. create_agent replaced LangGraph's prebuilt create_react_agent in LangChain 1.0, per the v1 migration guide.
Is Pydantic AI built on LangChain?
No. Pydantic AI is an agent framework from the team behind the Pydantic validation library, with its own agent loop, tools, evals and graph package (overview). See What is Pydantic AI.
Should I use LangChain or LangGraph?
Start with LangChain's create_agent if one agent with tools fits the job. Move to LangGraph when you need to define the nodes, edges and state yourself. LangGraph's docs describe it as a low-level framework that LangChain agents sit on, so you can mix them in one app.
Which one validates structured output?
All three can return typed output. Pydantic AI validates tool arguments and final answers against your types by default (overview). LangChain's create_agent takes a response_format and returns validated instances for Pydantic models (structured output). In LangGraph you add that step to your graph.
Are they free and open source?
The packages are MIT licensed on PyPI for Pydantic AI and LangChain. You still pay your model provider, and any hosted services you add.