LangChain is the better pick when your hard problem is agent orchestration: multi-step tool use, branching, durable state, retries and human approval, built on LangGraph. LlamaIndex is the better pick when your hard problem is retrieval: parsing messy documents, indexing them and getting the right evidence back. Both frameworks are free and MIT licensed, and many production stacks use both together.
Key takeaways
- LangChain, with LangGraph, leads on orchestration: durable state, checkpoints, interrupts and multi-agent patterns.
- LlamaIndex leads on the data layer: LlamaParse handles 130+ file formats, with hybrid search and recursive retrieval out of the box.
- Both frameworks are free and MIT licensed; the bill comes from the optional platforms, LangSmith and LlamaParse.
LangChain vs LlamaIndex is the most common framework question in AI development, and it is usually asked the wrong way. The two tools are not rivals doing the same job. They solve different halves of building an LLM application, and the right choice depends on where your complexity sits.
LangChain vs LlamaIndex: what is the difference?
LangChain is an agent framework built around the control flow of an LLM application: what the model does next, which tools it calls, what it remembers, and when a human must approve. LlamaIndex is a data framework built around your documents: parsing them, indexing them, and retrieving the right piece at the right time.
LangChain began as a library of chains and integrations and, with the 1.0 release, refocused on agents built on LangGraph. LlamaIndex began as GPT Index, a way to index private documents so an LLM could answer questions about them, and retrieval is still its centre of gravity. A short way to remember them: LlamaIndex is a data framework that learned to run agents, and LangChain is an agent framework that also does retrieval.
Both are free and MIT licensed. Both work with the same models, vector stores and embedding providers. The practical differences show up in retrieval depth, state management, language support and the paid platforms that sit on top.
How do LangChain and LlamaIndex compare at a glance?
LangChain leads on orchestration and durable state, while LlamaIndex leads on ingestion, parsing and retrieval primitives. For a standard RAG pipeline the overlap is large, and many teams end up using both.
| Dimension | LangChain + LangGraph | LlamaIndex |
|---|---|---|
| Centre of the design | Agent loop: model, tools, middleware | Data: documents, nodes, indexes, retrievers |
| Best primary use | Multi-step, stateful agents | Ingestion, parsing, indexing, retrieval |
| Current versions | langchain 1.4, langgraph 1.2 | llama-index 0.14, workflows 2.x |
| Ingestion and parsing | Document loaders, text splitters, 1,000+ integrations | LlamaParse: 130+ formats, 80+ languages; 158 reader packages |
| Retrieval primitives | Retrievers, hybrid search via vector stores, rerankers | Hybrid search, recursive retrieval, query decomposition, sub-question engines |
| Agent loop and state | LangGraph checkpointers, durable execution, time travel | Workflows: event-driven; checkpointing opt-in via WorkflowCheckpointer |
| Human-in-the-loop | interrupt() and resume, built-in middleware | Input and response events in Workflows |
| Languages | Python and TypeScript | Python (TypeScript port archived in 2026) |
| License | MIT | MIT |
| Managed platform | LangSmith: tracing, evals, deployment | LlamaParse: parsing, extraction, indexing |
The table hides one important fact: the frameworks are composable. LangChain even ships first-class LlamaIndex retriever integrations, because the retrieval depth can be valuable inside a LangChain agent, as LangChain's own comparison notes.
What is LlamaIndex best at?
LlamaIndex is best at the data layer. If your application lives or dies by retrieval quality, it gives you more levers to pull than any other framework: node parsers, ingestion pipelines, routers, response synthesizers, rerankers and a PropertyGraphIndex for knowledge-graph retrieval.
Its differentiator is LlamaParse, the hosted parsing platform formerly called LlamaCloud. It handles 130+ file formats and 80+ languages with layout-aware parsing, including dedicated extraction for charts, graphs and tables. Messy real-world documents — scanned PDFs, slide decks, spreadsheets with merged cells — are where it earns its keep.
LlamaIndex also ships 300+ integration packages, including 158 reader packages that extend ingestion to sources such as Google Drive, Notion, SQL databases and audio. Its core abstractions are documents, nodes, indexes, retrievers and query engines, and an agent usually sits on top of them. For a deeper look at securing the data these systems touch, see our guide to small business cybersecurity.
Where LlamaIndex is weaker is orchestration. Its Workflows abstraction is event-driven and step-based, with branching, retries and human review, and its AgentWorkflow coordinates multiple agents with handoffs. But checkpointing is not the default execution model: you opt in via WorkflowCheckpointer or serialize context yourself, or use a database integration. For a long-running agent that must survive a crash, that is real extra work.
What is LangChain best at?
LangChain is best at orchestration. Its agent abstraction in version 1.x is create_agent, a model calling tools in a loop, shaped by middleware and executed on the LangGraph runtime. LangGraph gives you low-level control over multi-step execution: branching, loops, durable state, retries, approvals and complex tool use.
Persistence is the sharpest difference. LangGraph treats persistence as a first-class citizen: every step of the graph reads from and writes to a checkpoint of the graph state. That makes interrupt-and-resume work — pause an agent for a human approval, then resume from exactly where it stopped — without extra wiring. Nodes before a checkpoint are not re-executed when you resume, because their results are already saved.
That durability is what makes multi-agent delegation safe in production. LangGraph supports four patterns: subagents that handle a focused subtask and merge results back, reusable skills, handoffs that transfer control between agents while preserving context, and routers that decide which agent to invoke based on the task. Each specialist can work independently while the overall system can pause, recover and continue without losing the thread.
LangChain also has the broader integration surface: 1,000+ integrations across models, vector stores, tools, embeddings and document loaders. Its retrieval building blocks — loaders, splitters, embeddings, vector stores and retrievers such as EnsembleRetriever and ParentDocumentRetriever — cover standard RAG well, and it promotes first-class LlamaIndex retriever integration when deeper retrieval is needed.
Which is better for RAG?
For retrieval-heavy RAG, LlamaIndex is usually the stronger starting point. It ships more retrieval machinery out of the box, and its loading and chunking abstractions are more coherent when your inputs are heterogeneous: PDFs, Notion pages, database rows and the long tail of formats that show up in real companies.
For RAG inside a larger agent, LangChain is usually the stronger choice. The retrieval step is one node in a graph that also calls tools, checks state, asks a human and writes results somewhere. LangGraph's checkpointing and interrupts matter more there than having five extra retriever types.
For a standard RAG pipeline the overlap is large. Both support the same models, vector stores, hybrid search, rerankers and MCP tools. Both ship evaluators — LlamaIndex has faithfulness, relevancy and correctness evaluators plus hit rate and MRR, while LangSmith offers judges for correctness, relevance and groundedness — and neither replaces a golden dataset labelled from your own documents. If retrieval quality is your main concern, build a small evaluation set first; the framework choice matters less than measuring what your retriever actually returns.
How much do LangChain and LlamaIndex cost?
Both frameworks cost nothing. The bill comes from the optional hosted platforms, plus the model tokens both stacks share. LangSmith Developer is free for one seat with 5,000 base traces a month, and Plus is $39 per seat per month with 10,000 base traces included, after which traces are pay-as-you-go. Enterprise is custom priced.
LlamaParse is credit-based. Its free tier includes 10,000 credits a month, pay-as-you-go costs $1.50 per 1,000 credits after that, and a Pro plan costs $500 a month. Some comparisons list an older $1.25 per 1,000 credit rate and a $50 Starter tier, so check the current pricing page before budgeting — both platforms changed their metering within 2026.
At solo-developer scale both platforms are effectively free. Costs grow differently after that: LangSmith bills per seat plus trace volume, so a large team with heavy tracing pays for seats first, while LlamaParse bills per credit, so a document-heavy pipeline pays for parsing volume first. Model tokens are billed by your model provider either way and usually dwarf both.
What does the code look like?
The code reflects the design centres. In LlamaIndex, the first thing you write is an index over your documents; in LangChain, the first thing you write is an agent that can call tools. Both are short to start and long to productionize.
A minimal LlamaIndex RAG app reads a folder of documents, builds a vector index and queries it. A minimal LangChain app defines tools and a model, then calls create_agent. The difference is what you reach for next: in LlamaIndex you reach for a different retriever or a query engine; in LangChain you reach for a graph node, a checkpointer or middleware.
Both frameworks changed shape in the past year, so pin exact versions and read the changelog before each upgrade. LlamaIndex is still 0.x, which means breaking changes are normal. LangChain 1.0 moved legacy chains, old retrievers and the hub module into a separate langchain-classic package, maintained for security fixes only through December 2026, so new code should use the agent and graph APIs.
What security issues should you watch for?
Both frameworks run untrusted content through an LLM, so the security questions are similar: prompt injection through retrieved documents, tool calls that reach the network or a database, and logs that capture sensitive data. Treat retrieved documents as untrusted input, not as instructions, and never let an agent execute a tool call it read from a document without a check.
LangGraph's interrupt-and-resume model helps here, because you can put a human approval gate before any consequential tool call: sending an email, running a database write, or calling a payment API. In LlamaIndex Workflows you can do the same with input and response events, but you wire it yourself. Either way, the gate belongs in the graph, not in a prompt asking the model to be careful.
Observability is a security control too. LangSmith traces the reasoning chain, not just whether a request failed, which is how you find out why an agent took a wrong turn. LlamaIndex integrates with tracing backends such as Phoenix, Langfuse and OpenTelemetry. If your agents touch customer data, check how traces are stored and who can read them, and read our spear phishing guide for the social-engineering side of the same threat.
How do you choose between LangChain and LlamaIndex?
Use a three-step framework. First, name the workload: orchestration or data retrieval. Second, consider starting without a framework at all if it is your team's first AI feature. Third, use both when needed, with LlamaIndex as a tool inside a LangGraph agent.
- Name the workload. If the model is choosing routes, tools, retry behaviour and multi-turn state, you are solving an orchestration problem and LangGraph fits. If it is deciding which documents are relevant and how to parse them, you are solving a data-layer problem and LlamaIndex fits.
- Prototype without a framework. Call the model API directly until the complexity requires a framework. A single agent with well-designed tools is simpler to build, reason about and debug than a multi-agent system.
- Combine them when both are hard. Wrap a LlamaIndex query engine as a tool that a LangGraph node invokes. LlamaIndex handles document retrieval, LangGraph runs the agent loop and manages durable state, and LangSmith traces the full flow end to end.
- Check the language. If your team builds in TypeScript, LangChain is the only real option of the two, since the LlamaIndex TypeScript port was archived.
- Budget the platforms, not the frameworks. Price LangSmith seats and traces against LlamaParse credits for your expected volume before you commit to either ecosystem.
What mistakes do teams make with either framework?
The most common mistake is picking one and trying to use it for everything. Teams build a retrieval system in LangChain and end up hand-rolling the retrievers LlamaIndex ships, or they build a stateful agent in LlamaIndex and end up hand-rolling the checkpointing LangGraph ships. Both are tools, not commitments.
The second mistake is skipping evaluation. Neither framework's built-in evaluators replace a golden dataset labelled from your own documents. Build the dataset early, score retrieval and answers against it, and re-run it on every framework upgrade.
The third mistake is shipping without observability. When an agent takes 200 steps over two minutes and makes a mistake somewhere along the way, there is no stack trace, because no code failed — the reasoning failed. Without tracing you cannot see what changed, so you end up guessing why it failed based only on the final output.
The bottom line
Choose LlamaIndex when ingestion and retrieval are the hard part: messy documents, many formats and advanced retrieval. Choose LangChain with LangGraph when the hard part is a multi-step, stateful agent with human approval. Use both when you need both, which is a pattern LangChain itself documents.
Either way, the framework is the cheap part. The real work is the evaluation dataset, the approval gates on consequential actions, and the observability that tells you why an agent failed. Get those right and either framework will serve you well — and if you want to check the security posture of the site your agent runs on, start with our free security headers checker.
Frequently asked questions
Can I use LangChain and LlamaIndex together?
Yes, and it is a common production pattern. Wrap a LlamaIndex query engine as a tool that a LangGraph node calls: LlamaIndex handles parsing, indexing and retrieval, while LangChain handles the agent loop, state and human approval. LangSmith can trace the full flow.
Is LangChain or LlamaIndex better for RAG?
LlamaIndex is usually the stronger starting point for retrieval-heavy RAG, because it ships more retrieval machinery out of the box, including hybrid search, recursive retrieval and query decomposition. LangChain covers standard RAG well and is stronger when the RAG pipeline sits inside a larger agent.
Are LangChain and LlamaIndex free?
Yes. Both framework repositories are MIT licensed and free to use. The optional hosted platforms cost money: LangSmith has a free Developer plan with 5,000 base traces a month and a Plus plan at $39 per seat per month, while LlamaParse has 10,000 free credits a month and then charges per credit.
Which one is better for agents?
LangChain, built on LangGraph, is the stronger agent framework. LangGraph saves state through a checkpointer after every step, which makes interrupt-and-resume, retries and durable multi-agent execution work by default. LlamaIndex Workflows are event-driven and capable, but checkpointing is opt-in rather than the default.
Does LlamaIndex work with TypeScript?
No, not anymore. The LlamaIndex TypeScript repository was archived in 2026, so LlamaIndex is effectively Python-only. LangChain supports both Python and TypeScript, which matters if your team builds in JavaScript.
What is LlamaParse?
LlamaParse is LlamaIndex's hosted document parsing platform, formerly called LlamaCloud. It parses, extracts, classifies, splits and indexes documents across 130+ file formats and 80+ languages, and it can be used with or without the LlamaIndex framework.
What is LangSmith?
LangSmith is LangChain's framework-agnostic platform for observability, evaluation and deployment. It traces agent runs, scores outputs with LLM-as-judge and code-based evaluators, and deploys agents. It works with LangChain, LangGraph, LlamaIndex, the OpenAI and Anthropic SDKs, and custom code.
Which should a beginner choose?
Start without either framework if your first AI feature is simple: call the model API directly until the complexity justifies a framework. When you do need one, pick LlamaIndex if documents are the hard part and LangChain if multi-step agent behaviour is the hard part.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against LangChain's own comparison, the LlamaIndex and LangGraph documentation, and the LangSmith and LlamaParse pricing pages.
How we write and fact-check →