LangChain vs LlamaIndex: The Short Answer
Both are open-source Python and TypeScript frameworks for building with LLMs. For years, the simple rule was "LangChain for agents and chains, LlamaIndex for RAG over your data." That's still a decent starting point, but both have grown into each other's space.
In October 2025, LangChain and LangGraph both reached 1.0, reshaping LangChain around a single agent abstraction built on LangGraph. LlamaIndex, meanwhile, added Workflows for multi-step agents. Here's how they compare now.
🎯 Quick Answer (30-Second Read)
- LangChain 1.0 centres on
create_agent()plus middleware, running on LangGraph underneath. Older APIs likeAgentExecutorare legacy. - LangGraph is the low-level runtime for stateful, graph-based agents with persistence and human-in-the-loop.
- LlamaIndex shines at data ingestion, indexing and retrieval (RAG), with an event-driven Workflows system for agents.
- Common combo: LlamaIndex for retrieval, LangGraph for orchestration.
- Often the right answer is neither: for simple apps, the model provider's SDK plus a few functions is easier to debug.
What Each One Is For
Agents that call tools, multi-step workflows with state, branching, retries, human approval and memory. Huge integration catalogue.
Loading documents (PDFs, Notion, databases), chunking, indexing, advanced retrieval and query engines, plus Workflows for agentic RAG.
PDF, web, DBs"] --> L2["Chunking +
embeddings"] --> L3["Index +
retrievers"] --> L4["Query engine"] end subgraph LG["LangChain / LangGraph strengths"] G1["create_agent
+ middleware"] --> G2["Tools
(APIs, search, code)"] G1 --> G3["State, memory,
human-in-the-loop"] end L4 -->|"used as a retrieval tool"| G2
Code: A Simple Agent (LangChain 1.0)
from langchain.agents import create_agent
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"It's 31°C and sunny in {city}."
agent = create_agent(
model="anthropic:claude-sonnet-5-5",
tools=[get_weather],
system_prompt="You are a helpful travel assistant.",
)
result = agent.invoke({"messages": [{"role": "user", "content": "Weather in Pune?"}]})
print(result["messages"][-1].content)Code: RAG Over Your Documents (LlamaIndex)
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
docs = SimpleDirectoryReader("./company-docs").load_data()
index = VectorStoreIndex.from_documents(docs) # chunk + embed + index
engine = index.as_query_engine()
print(engine.query("What is our refund policy?"))Both libraries need provider packages and API keys configured; check each project's quickstart for the current setup.
Head-to-Head
| LangChain / LangGraph | LlamaIndex | |
|---|---|---|
| Core strength | Agents, orchestration, tool calling | Data ingestion, indexing, retrieval |
| Agent model | Graph of nodes with typed state (LangGraph) | Event-driven async Workflows |
| RAG tools | Good, many integrations | Deeper: advanced retrievers, query engines |
| Integrations | Very large catalogue | Large, especially data connectors (LlamaHub) |
| Learning curve | Simpler since 1.0 (create_agent) |
Easy for basic RAG, deeper for advanced |
| Commercial add-ons | LangSmith (tracing, evals) | LlamaCloud (parsing, managed indexes) |
Which Should You Choose?
over documents"| R{"Complex parsing /
retrieval needs?"} S -->|"Agent that uses tools,
multi-step workflows"| A["LangChain create_agent
→ LangGraph for control"] S -->|"Both"| B["LlamaIndex retrieval
+ LangGraph orchestration"] R -->|Yes| LI["LlamaIndex"] R -->|"No, simple RAG"| N["Either, or just the
model SDK + vector DB"]
AgentExecutor, initialize_agent or old chain classes, the code is outdated. Check the version a tutorial uses before copying it.
When to Skip Frameworks
Frameworks add abstraction layers. For a chatbot with a few tools, the Anthropic or OpenAI SDK with tool calling is often clearer and easier to debug. Reach for a framework when you need what it provides: many integrations, durable state, complex retrieval, or tracing and evaluation tooling.
Frequently Asked Questions
Is LlamaIndex better than LangChain for RAG?
LlamaIndex is generally considered stronger for complex retrieval: document parsing, many index types and advanced query engines. LangChain handles standard RAG well too. Many teams use LlamaIndex for retrieval and LangChain or LangGraph for orchestrating agents.
What changed in LangChain 1.0?
LangChain 1.0, released in October 2025 alongside LangGraph 1.0, centres on a create_agent function with middleware for customisation, built on the LangGraph runtime. Older agent APIs such as AgentExecutor became legacy.
Can I use LangChain and LlamaIndex together?
Yes. A common pattern uses LlamaIndex to load, index and retrieve documents, exposing retrieval as a tool, while LangChain or LangGraph runs the agent that decides when to call it alongside other tools.
Conclusion
Choose LangChain (with LangGraph) when your main challenge is orchestrating agents, tools and state. Choose LlamaIndex when your main challenge is getting the right information out of your documents. Combine them for agentic RAG, and skip both when a plain SDK does the job.
Sources
- LangChain docs: Agents (create_agent)
- LangGraph documentation
- LlamaIndex documentation
- LlamaIndex: Workflows
Last verified: 2 November 2026.
Related reads: RAG vs Fine-Tuning · How AI Agents Work · How to Build an MCP Server in Python · Vector Databases Explained
I write about building with AI and how real products work. Follow on LinkedIn or X, or invite me to speak.