LangChain vs LlamaIndex vs Pydantic AI vs OpenAI Agents SDK
These four are the frameworks teams actually shortlist once they move past a script in a notebook. The split is not Python versus TypeScript — it is whether retrieval, types or a thin loop is the centre of the problem.
Short answer
Choose on the shape of the job. LlamaIndex when retrieval and connectors are the product; Pydantic AI when schema-safe tool calls are the risk; OpenAI Agents SDK when you want a small loop with handoffs and guardrails built in; LangChain when you need the widest integration surface and will pay the abstraction tax.
By Kunj Shah · Licence and cost facts verified · method
- LangChainWidest integrations, largest surface.
- LlamaIndexRetrieval and indexing as the main event.
- Pydantic AIType-safe tools and structured agent outputs.
- OpenAI Agents SDKSmall primitives: handoffs, guardrails, tracing.
| Dimension | LangChain | LlamaIndex | Pydantic AI | OpenAI Agents SDK |
|---|---|---|---|---|
| Best for | Breadth — many providers, tools and patterns already wired | RAG-heavy apps where data connectors matter | Agents where bad tool args are the main failure mode | A legible loop without adopting a whole platform |
| Retrieval built in | Via integrations, not the core abstraction | First-class — indexes, parsers and query engines | Via your own retrieval layer | Bring your own context |
| Type safety | Optional, varies by module | Moderate — Python-first data models | Strong — Pydantic models end to end | Moderate — typed runners and tools |
| Multi-agent patterns | Graphs, crews and handoffs via ecosystem | Workflows and agents over indexes | Delegation between typed agents | Handoffs as a first-class primitive |
| Operational surface | Large — many moving parts to learn | Medium — data stack plus agent layer | Small core — you own orchestration | Smallest — intentionally minimal API |
| Where it loses | Teams that want a thin, readable core | Pure tool loops with no retrieval | Batteries-included multi-provider glue | Deep retrieval tooling out of the box |
Scroll the table sideways to see every tool.
What this table is not. These are editorial judgements, not benchmarks: Lattice has not run these tools head to head, and no cell uses GitHub stars or vendor benchmark claims as evidence. Licence and cost facts are re-checked on a schedule the build enforces — the receipt is public.
The recommendation
Which should you choose: LangChain, LlamaIndex, Pydantic AI or OpenAI Agents SDK?
Choose on the shape of the job. LlamaIndex when retrieval and connectors are the product; Pydantic AI when schema-safe tool calls are the risk; OpenAI Agents SDK when you want a small loop with handoffs and guardrails built in; LangChain when you need the widest integration surface and will pay the abstraction tax. Whichever you pick, run the loop on a durable host and trace every tool call — no framework replaces those.
Rules of thumb
- A framework orchestrates calls inside one process. It does not make long runs survive a deploy — that is a workflow engine's job.
- Fewer tools beats a longer system prompt. Narrow the agent before you add another integration.
- If you cannot trace a failing run step by step, you are debugging prose instead of the call that went wrong.
Quick answers
- When should you use LangChain, and when should you skip it?
- Use LangChain when: tool use and state, in an ecosystem where the answers already exist. Skip it when: you want a thin, legible core — this is a large surface.
- When should you use LlamaIndex, and when should you skip it?
- Use LlamaIndex when: data-centric work where retrieval is the centre of the problem. Skip it when: you need agent orchestration more than data access.
- When should you use Pydantic AI, and when should you skip it?
- Use Pydantic AI when: type-safe agents where schema correctness is the priority. Skip it when: you want a batteries-included ecosystem.
- When should you use OpenAI Agents SDK, and when should you skip it?
- Use OpenAI Agents SDK when: a small, legible set of primitives for handoffs and guardrails. Skip it when: you need multi-provider abstraction at every layer.