# LlamaIndex vs LangChain: how they differ and which to use

> LlamaIndex starts from your data (loading, indexing, retrieval). LangChain starts from the agent loop. Both do RAG and agents.

Source: https://www.honeyhive.ai/learn/llamaindex-vs-langchain (updated 2026-11-04)

LlamaIndex and LangChain overlap, but they start from different places. LlamaIndex starts from your data: it calls itself "our original open-source toolkit for RAG and agents" and is organised around loading, indexing and querying documents ([LlamaIndex docs](https://developers.llamaindex.ai/python/framework/)). LangChain starts from the agent loop: it provides `create_agent`, "a minimal, highly configurable agent harness" ([LangChain docs](https://docs.langchain.com/oss/python/langchain/overview)). Pick LlamaIndex when retrieval over your own documents is the hard part. Pick LangChain when controlling an agent's tools and behaviour is.

Both are open source under the MIT license ([LlamaIndex](https://github.com/run-llama/llama_index), [LangChain](https://github.com/langchain-ai/langchain)). Many older comparisons describe LangChain as chains and LlamaIndex as an index. LangChain v1 changed that: legacy chains, retrievers and the indexing API moved to the `langchain-classic` package ([v1 migration guide](https://docs.langchain.com/oss/python/migrate/langchain-v1)), and its agents now run on LangGraph ([overview](https://docs.langchain.com/oss/python/langchain/overview)).

## Side by side

| | LlamaIndex | LangChain |
|---|---|---|
| Starting point | Your data: "context-augmentation use case[s]" ([docs](https://developers.llamaindex.ai/python/framework/)) | The agent loop and its harness ([docs](https://docs.langchain.com/oss/python/langchain/overview)) |
| RAG building blocks | Documents, Nodes, indexes, retrievers, routers, node postprocessors, response synthesizers ([RAG guide](https://developers.llamaindex.ai/python/framework/understanding/rag/)) | Load, split, embed, store, then retrieve and generate ([RAG tutorial](https://docs.langchain.com/oss/python/langchain/rag)) |
| Agents | "LLM-powered assistants that use tools to complete tasks" ([docs](https://developers.llamaindex.ai/python/framework/)); multi-agent through hand-offs ([agents](https://developers.llamaindex.ai/python/framework/module_guides/deploying/agents/)) | `create_agent`, shaped by middleware ([overview](https://docs.langchain.com/oss/python/langchain/overview)) |
| Multi-step orchestration | Workflows, event-driven ([docs](https://developers.llamaindex.ai/python/framework/)) | LangGraph, "our low-level orchestration framework" ([overview](https://docs.langchain.com/oss/python/langchain/overview)); see [LangGraph](/learn/langgraph-framework) |
| Higher-level agent harness | AgentWorkflow groups agents ([agents](https://developers.llamaindex.ai/python/framework/module_guides/deploying/agents/)) | Deep Agents, with "context compression, virtual filesystem, subagents" ([overview](https://docs.langchain.com/oss/python/langchain/overview)) |
| Model providers | Separate integration packages; the README cites "over 300 LlamaIndex integration packages" ([GitHub](https://github.com/run-llama/llama_index)) | "Supports OpenAI, Anthropic, Google, and more" through one interface ([overview](https://docs.langchain.com/oss/python/langchain/overview)) |
| Evaluation in the docs | Evaluation is the fifth RAG stage: "objective measures of how accurate, faithful and fast your responses to queries are" ([RAG guide](https://developers.llamaindex.ai/python/framework/understanding/rag/)) | The RAG tutorial has no evaluation stage; it links "Evaluate a RAG application" under next steps and includes a tracing step ([RAG tutorial](https://docs.langchain.com/oss/python/langchain/rag)) |
| Install | `llama-index` starter, or `llama-index-core` plus the integrations you pick ([GitHub](https://github.com/run-llama/llama_index)) | See [LangChain](/learn/langchain-framework) |

## How their RAG differs

Both follow the same shape: load documents, split them, embed, store, retrieve, then have a model answer from what was retrieved ([LlamaIndex](https://developers.llamaindex.ai/python/framework/understanding/rag/), [LangChain](https://docs.langchain.com/oss/python/langchain/rag)). For the general pattern, see [RAG pipelines](/learn/rag-pipeline) and [agentic RAG](/learn/agentic-rag).

The difference is how much of that shape is a named object. LlamaIndex gives each step a component: Nodes as "the atomic unit of data," routers that "determine which retriever will be used to retrieve relevant context from the knowledge base," and postprocessors that filter or re-rank retrieved nodes ([RAG guide](https://developers.llamaindex.ai/python/framework/understanding/rag/)). The LangChain tutorial is shorter on retrieval structure. It shows a splitter (`chunk_size=1000, chunk_overlap=200` in its example), a vector store and a retriever, then leaves the rest to the agent ([RAG tutorial](https://docs.langchain.com/oss/python/langchain/rag)). Its newer RAG patterns lean on Deep Agents, such as "retrieve, offload, and delegate" ([RAG tutorial](https://docs.langchain.com/oss/python/langchain/rag)).

## How their agents differ

LlamaIndex defines an agent as "a specific system that uses an LLM, memory, and tools, to handle inputs from outside users," and builds multi-agent systems by letting agents hand off control to each other ([agents](https://developers.llamaindex.ai/python/framework/module_guides/deploying/agents/)). LangChain defines the agent loop in `create_agent` and changes its behaviour with middleware ([overview](https://docs.langchain.com/oss/python/langchain/overview), [LangChain](/learn/langchain-framework)). For the wider landscape, see [agent orchestration](/learn/agent-orchestration) and [multi-agent systems](/learn/multi-agent-systems).

## Which to choose

| If your main problem is | Start with |
|---|---|
| Getting many document formats into an index and tuning retrieval | LlamaIndex |
| Controlling an agent's tools, retries, approvals and fallbacks | LangChain |
| Stateful, branching, long-running agent flows | LangGraph, or LlamaIndex Workflows |

This table is a judgement from the docs above, not a benchmark. Do not choose on GitHub stars or a speed claim from a third-party comparison; run your own retrieval and task tests on your own data. See [LLM evaluation](/learn/llm-evaluation).

## Tracing and evaluating either one

Whichever you pick, you need traces to debug retrieval and agent steps. HoneyHive's docs cover both through OpenInference instrumentors, which capture "query engine operations, LLM calls, retrieval, embeddings" for LlamaIndex and "agent runs, tool calls, chain executions, and LLM interactions" for LangChain ([LlamaIndex integration](https://docs.honeyhive.ai/v2/integrations/llamaindex), [LangChain integration](https://docs.honeyhive.ai/v2/integrations/langchain)). The LangChain integration needs Python 3.11 or later and `langchain` 1.0.0 or later ([LangChain integration](https://docs.honeyhive.ai/v2/integrations/langchain)). For what to look at in traces, see [LLM observability](/learn/llm-observability).

## FAQ

### Is LlamaIndex better than LangChain?

Neither is better in general. LlamaIndex's docs frame it as a toolkit for RAG and agents over your own data ([LlamaIndex docs](https://developers.llamaindex.ai/python/framework/)). LangChain's docs frame it as an agent harness with middleware ([LangChain docs](https://docs.langchain.com/oss/python/langchain/overview)). Pick by the part of the problem that is hardest for you.

### Can I use LlamaIndex and LangChain together?

Yes. LlamaIndex documents a `LangChainLLM` wrapper (`pip install llama-index-llms-langchain`) that lets LlamaIndex use a LangChain model ([LlamaIndex docs](https://developers.llamaindex.ai/python/framework/integrations/llm/langchain/)). Test any combined setup on your own data before committing.

### Are LlamaIndex and LangChain free?

Both repositories are MIT licensed ([LlamaIndex](https://github.com/run-llama/llama_index), [LangChain](https://github.com/langchain-ai/langchain)). You still pay for the model and vector store you connect.

### Which is the LlamaIndex equivalent of LangGraph?

LlamaIndex Workflows, which its docs call "event-driven, multi-step processes that combine agents, data connectors and tools" ([LlamaIndex docs](https://developers.llamaindex.ai/python/framework/)). LangGraph is LangChain's "low-level orchestration framework" ([LangChain docs](https://docs.langchain.com/oss/python/langchain/overview)). See [LangGraph](/learn/langgraph-framework).

### How do I trace and evaluate apps built with either?

Both can be instrumented with OpenInference packages that emit OpenTelemetry-style traces, and HoneyHive documents both ([LlamaIndex](https://docs.honeyhive.ai/v2/integrations/llamaindex), [LangChain](https://docs.honeyhive.ai/v2/integrations/langchain)).
