The short answer

Here is the whole comparison in three sentences. LangChain is a general-purpose toolkit for wiring language models to prompts, tools and data — the Swiss Army knife you reach for first. LlamaIndex is specialised for one job: connecting a model to your own documents and data so it can answer questions about them (retrieval-augmented generation, or RAG). LangGraph is a lower-level library, from the LangChain team, for building agents that loop, branch and remember state across many steps.

They are not really rivals. A common setup uses LlamaIndex for retrieval, LangChain for the surrounding orchestration, and LangGraph when the workflow becomes a genuine multi-step agent. The rest of this guide explains when each earns its place, and the full landscape — DSPy, CrewAI, AutoGen and more — is compared in our LLM frameworks guide.

Rule of thumb. Building a chatbot over your own documents? Start with LlamaIndex. Gluing several tools and models into a pipeline? LangChain. Building an agent that plans, acts and revises over many turns? LangGraph.

LangChain: the general-purpose toolkit

LangChain is the framework most people meet first, and for good reason. It provides ready-made building blocks — prompt templates, model wrappers, memory, output parsers, and "chains" that link steps together — plus one of the largest libraries of integrations in the ecosystem, covering hundreds of models, vector stores and external tools. If you want to prototype an idea quickly without writing plumbing for every provider, LangChain gets you moving fast.

The trade-off is abstraction. LangChain's convenience layers can obscure what is actually being sent to the model, which some experienced teams find frustrating when they need fine control or are debugging odd behaviour. The framework has matured considerably in response, splitting into a leaner core with optional add-ons. For general orchestration, integrations and rapid prototyping, it remains the default choice — and it pairs naturally with a standard like MCP for connecting to external tools.

LlamaIndex: built for retrieval and RAG

LlamaIndex (once called GPT Index) is built around a single, common need: making a model answer questions about your data — internal documents, a knowledge base, a set of PDFs. It handles the unglamorous but critical parts of RAG well: loading and chunking documents, building indexes, and retrieving the most relevant passages to feed the model at query time.

If your project is essentially "chat with our documents", LlamaIndex will usually get you a good result faster than a general toolkit, because retrieval is its whole reason to exist. It offers a range of index types and retrieval strategies out of the box, and it plays well alongside LangChain — many teams use LlamaIndex for the retrieval layer and LangChain for everything around it. For a broader look at where retrieval fits, see the frameworks guide.

LangGraph: stateful, multi-step agents

LangGraph is the newest of the three and the most different. Instead of linear chains, it models an application as a graph of steps, with explicit state that persists as control flows between them. That makes it well suited to agents that need to loop, branch on results, pause for human approval, or retry when something fails — the kind of control that linear chains handle awkwardly.

Because it is lower-level, LangGraph asks more of you up front, but gives back precision and predictability. It is the right tool when your "chain" has really become an agent — something that plans, takes actions, observes the outcome and decides what to do next. For simple request-response tasks it is overkill; for durable, multi-actor workflows it is where the LangChain ecosystem is clearly heading.

Side by side

LangChainLlamaIndexLangGraph
Best forGeneral orchestration, prototypingRAG over your own dataStateful, multi-step agents
Core ideaChains + integrationsIndexing + retrievalGraphs + persistent state
LevelHigh-level, batteries-includedFocused, high-level for RAGLower-level, explicit control
Learning curveGentle to startGentle for document Q&ASteeper
Typical useChatbots, tool pipelinesDocument Q&A, knowledge basesAutonomous agents, workflows

The columns overlap on purpose: LangChain can do basic retrieval, LlamaIndex can do light orchestration, and LangChain ships its own agent tooling. The table shows where each is strongest, not the only thing it can do.

Which should you choose?

Match the tool to the job rather than looking for a single winner:

  • Chat over your documents — start with LlamaIndex. Retrieval quality is what makes or breaks these projects, and that is its speciality.
  • Prototype that glues models and tools togetherLangChain. The integrations and abstractions save days of plumbing.
  • Agent that plans and acts over many stepsLangGraph, once your logic outgrows a linear chain.
  • All of the above — combine them. LlamaIndex for retrieval, LangChain for orchestration, LangGraph when the workflow becomes stateful.

Whatever you pick, keep the model layer swappable and connect to external tools through an open standard such as MCP, so you are not locked in. And if none of the three fits, the wider field — DSPy for prompt optimisation, CrewAI and AutoGen for multi-agent systems — is compared in our LLM frameworks guide.