Skip to content
Ali Hassan, home

Blog6 min read

LlamaIndex vs LangChain: which one for your RAG app

LlamaIndex vs LangChain for RAG apps: what each is built for, where they overlap, and the LangChain alternatives worth a look. Check which fits your app.

By Ali Hassan, Senior engineer for SaaS and AI products

LlamaIndex vs LangChain is the choice most teams face when they start a retrieval app, and the two are not really rivals. One began as a data framework for indexing and retrieval; the other began as an orchestration layer for chaining model calls and tools. This post covers what each is for, where they overlap, their licences and languages, a decision table, and the LangChain alternatives worth a look.

What does each one do?

The LlamaIndex vs LangChain question is really about which first problem you are solving. LlamaIndex began as a data framework: its docs call it a Python toolkit for building model-powered agents over your own data. Its strengths are indexing, retrieval and query engines. LangChain began as an orchestration layer: its docs describe create_agent as a small agent harness. It wraps the model loop with prompts, tools and middleware. One starts from your documents. The other starts from the control flow.

The LlamaIndex framework docs list retrieval, agents, workflows, structured extraction and chatbots as its jobs. The LangChain overview puts the model loop at the centre and builds its agents on top of LangGraph. Either can run a plain retrieval pipeline. The difference is what each one makes easy. In practice LlamaIndex hands you higher-level index and query-engine objects. LangChain hands you an agent runtime and a bigger set of tool and prompt helpers. You rarely need both. So lead with the one whose easy path matches your hard problem.

Where do LlamaIndex and LangChain overlap?

They overlap more than their origin stories suggest. Both now ship agents, tool calling, retrieval, memory and a long list of model and vector-store integrations, so either can answer questions over your documents. LlamaIndex has grown orchestration and workflow features. LangChain has grown retrieval and indexing helpers. For a standard retrieval feature in 2026, either will do the job. The LlamaIndex vs LangChain choice is about fit, not a missing feature.

LlamaIndex's repository calls it an open-source framework to build agentic applications, not just a retrieval library. LangChain's repository calls itself a framework for building agents and model-powered applications. Both read as agent frameworks now, so the pick comes down to where your app's centre of gravity sits. The overlap stops at the defaults. LlamaIndex still makes indexing and retrieval the short path; LangChain still makes multi-step tool use the short path. You can push either tool into the other's lane, but you feel the friction in the extra code you write to get there.

Licences and languages: what are you adopting?

Both are free to adopt, with a difference in languages. I checked each project's GitHub page on 30 November 2026: LangChain and LlamaIndex both ship under the MIT licence, so commercial use is unrestricted. The language story is where they split. LangChain has a first-class JavaScript and TypeScript port. LlamaIndex is Python first, so a Node team should weigh that early.

LangChain's main repository is MIT, and the separate LangChain.js repository is MIT and written in TypeScript, so a Node stack is covered. LlamaIndex's repository is MIT, and its framework docs describe a Python toolkit. Put the other way, langchain vs llamaindex is the same question seen from the other side: retrieval-first or orchestration-first.

A decision table

Here is the short version. The LlamaIndex vs LangChain pick comes down to what sits at the centre of your app: your documents and retrieval quality, or the agent control flow and tool use. Neither choice locks you in. Both are MIT, and both plug into the same models and vector stores. The table maps a common need to the tool that makes it easier, not the only one that can do it.

What you care about mostLeans LlamaIndexLeans LangChain
Indexing and retrieval over your dataCore strengthSupported
Agent control flow and tool useSupportedCore strength, via LangGraph
TypeScript or Node stackPython firstPython and TypeScript
Document answers with citationsStrong fitStrong fit
Licence (checked 30 Nov 2026)MITMIT

The LlamaIndex framework docs and the integrations each project lists keep growing, so treat the table as a starting point, not a verdict.

What are the LangChain alternatives?

If LangChain feels heavier than your app needs, the main LangChain alternatives are LlamaIndex, Haystack and plain SDK calls. LlamaIndex suits retrieval-first apps. Haystack is an orchestration framework from deepset, built around modular pipelines. Plain SDK calls, the model provider's own client and a few lines of code, win when you have one prompt and one tool and do not need a framework at all.

I read Haystack's repository on 30 November 2026. It describes an open-source framework for production model apps, in Python, under the Apache 2.0 licence. For a single call, the provider SDK beats any framework: fewer dependencies and less to learn. A rough rule: pick LlamaIndex when retrieval quality is the hard part, pick Haystack when you want typed pipelines you can test end to end, and pick raw SDK calls when a framework would be scaffolding you never grow into. The fixed pipeline underneath is the one I lay out in RAG architecture.

What did I use on a real RAG app?

On AI PDF Chat, a multi-document assistant where every answer cites its PDF and page, I used LangChain. It runs on Qdrant for vectors, Gemini embeddings and Groq running Llama for generation, behind a Next.js and Express app. The model provider had to be swappable. Its integrations turned that into a settings change, not a rewrite.

The ingestion is a background queue: an upload returns at once and each file is extracted, chunked and embedded one file at a time, with per-user vectors kept apart so one person never sees another's documents. A failed embedding is retried with backoff, and a scanned PDF with no text is marked failed rather than shown as ready, so a bad file never quietly spoils an answer. None of that is special to LangChain, but its integrations let me wire embeddings, the vector store and the chat model from settings. As of 2026, it still supports every provider I reached for. The LangChain overview shows the harness that made the provider swap cheap. You can see the build on AI PDF Chat.

When should you bring in help?

If you are weighing LlamaIndex vs LangChain for a new retrieval app, or you inherited one that works in a demo and struggles in production, that is the kind of thing I sort out. I start from your data and your questions, pick the lighter tool that fits, and keep the answers measurable.

Both frameworks are MIT and free, so in 2026 the real cost is engineering time and model tokens: a chatty agent runs the model several times per question, and at $2 per million input tokens for a mid-tier model, that shows up on the bill. I build retrieval over your own content and prove where each round earns its cost. You can see the shape of it on RAG development.

From the work

  • PDF chat with document scope selector, landing page and upload queue of a RAG assistant that cites its pages.

    AI PDF Chat

    Upload several PDFs and ask questions across all of them or one; every answer cites the PDF and page, and the citation opens the passage highlighted.

    • Next.js
    • Express
    • LangChain
  • AI reply grounded in cited help-centre content, shadow-mode draft metrics per channel, and metered AI credits in billing.

    Evoriqa

    My own SaaS: a multi-tenant AI customer-support platform, live in production, built by the person who also pays its inference bill.

    Live in production

    • Next.js
    • TypeScript
    • PostgreSQL

The offer this article leads to: RAG development, typically $4k-$10k.

Tell me what you’re building and where it’s stuck.

I’ll tell you the cleanest path forward, including if it’s “don’t build that.”

Email only, on purpose: it reaches me, not a sales team.

Or write tocontact@alihassan.dev

Ali Hassan in a dark winter jacket, looking off to one side, standing in a stone courtyard with a minaret and cloudy sky behind him.