COMPARISONS · AI FRAMEWORKS

LangChain alternatives in 2026: 10 frameworks for agents and RAG

AUTHOR · XERJ documentation team · REVIEWED BY · XERJ engineering team · PUBLISHED · 2026-11-23 · UPDATED · 2026-11-23
SHORT ANSWER · UPDATED 2026-11-23

What are the best LangChain alternatives in 2026? For RAG over documents, LlamaIndex or Haystack. For typed Python agents, Pydantic AI or the OpenAI Agents SDK. For teams of agents, CrewAI. For optimizing prompts with code, DSPy. For TypeScript, Mastra or the Vercel AI SDK. For long running stateful agents from the LangChain team, LangGraph.

Key number: CrewAI has 61,199 GitHub stars, LlamaIndex 52,987, LangGraph 45,307 and DSPy 39,194. LangChain itself has 149,991.

Stars, licences, languages and releases checked on GitHub on 23 Nov 2026. Feature notes come from each project README read the same day.

TL;DR LangChain is the most starred framework for LLM apps, with integrations and composable components for agents. Teams compare alternatives when they want a smaller API, a different language, a stronger RAG focus or a specific agent style. LlamaIndex and Haystack lead for document pipelines and RAG. Pydantic AI and the OpenAI Agents SDK keep agents small and typed. CrewAI organizes role based teams of agents. DSPy replaces hand written prompts with optimized programs. Mastra and the Vercel AI SDK serve TypeScript. Whatever you pick, XERJ can be the search tool your agent calls over MCP.

TOOL · FILTER

Find the LangChain alternative that fits your stack

I need

Sort by

FrameworkBest forLanguageLicenceStarsLatest
LangChainIntegrations and composable components (the baseline)Python (LangChain.js for JS)MIT149,991langchain-core 1.8.4
CrewAIRole based agent teams (Crews) and event driven FlowsPythonMIT61,1991.15.44
LlamaIndexDocument agents and RAG, 300+ integration packagesPythonMIT52,987v0.14.26
LangGraphLong running, stateful agents with durable executionPython (LangGraph.js for JS)MIT45,3071.2.24
DSPyPrograms instead of prompts, with prompt and weight optimizersPythonMIT39,1943.5.0
OpenAI Agents SDKLight multi agent workflows with handoffs, guardrails and tracingPython (JS/TS version too)MIT30,839v0.25.0
MastraTypeScript agents, graph workflows, RAG and MCP serversTypeScriptApache 2.0 (ee folders under their own licence)29,762@mastra/core 1.84.0
Semantic KernelModel agnostic agents for .NET, Python and JavaC#, Python, JavaMIT28,794dotnet-1.82.0
Vercel AI SDKProvider agnostic TypeScript toolkit for AI apps and agentsTypeScriptApache 2.028,141ai on npm
HaystackModular pipelines for RAG, search and agentsPythonApache 2.027,083v3.5.0
Pydantic AITyped agent loop, model fallback, evals and Pydantic GraphPythonMIT21,351v2.71.0
XERJThe search tool your agent calls: local index of files, code and docsRust binary, any client over MCP or RESTApache 2.020,186v1.0.0-rc.104

Stars, licences and latest release tags from the GitHub API on 23 Nov 2026. Tags only mark what each README says today, so a framework without a tick may still support it through plugins. Tick boxes to keep only the frameworks that match all of them.
PASTE THIS TO YOUR AI AGENT. IT DOES THE REST Read https://xerj.org/compare/langchain-alternatives-2026.md. I use LangChain today. Ask me about my language, my use case (RAG, single agent or a team of agents) and how I deploy, then tell me which framework fits and what a migration would take.

Pick one in ten seconds

Why people look for a LangChain alternative

LangChain covers a lot of ground, from model wrappers to agents, and its integrations list is the largest in the field. Teams usually compare alternatives when they want one of four things: a smaller surface to learn, a framework built around RAG and documents, a specific agent style such as typed agents or agent teams, or first class support for another language such as TypeScript or C#.

When to choose LlamaIndex or Haystack

Choose LlamaIndex when your app is about documents. Its README describes a framework for agentic applications with more than 300 integration packages, and the company now focuses on document parsing and extraction with LlamaParse. Choose Haystack when you want explicit, modular pipelines with clear control over retrieval, routing, memory and generation.

When to choose LangGraph

Choose LangGraph when you like the LangChain ecosystem and need long running, stateful agents. Its README lists durable execution that resumes after failures, human in the loop, short and long term memory, and deployment through LangSmith. It works standalone or with LangChain components.

When to choose Pydantic AI or the OpenAI Agents SDK

Choose Pydantic AI for a typed agent loop where every model is a string swap away, with evals and Pydantic Graph for flows. Choose the OpenAI Agents SDK for light multi agent workflows with handoffs, guardrails, sessions and tracing; its README says it is provider agnostic and supports more than 100 LLMs, with tools from functions, MCP and hosted tools.

When to choose CrewAI or DSPy

Choose CrewAI when the work splits into roles: Crews give agents roles and let them collaborate, and Flows give event driven control around them. Choose DSPy when prompt tuning takes too much time: you write modular Python and let its optimizers improve prompts and weights against your metric.

When to choose Mastra, the Vercel AI SDK or Semantic Kernel

Choose Mastra for TypeScript agents with graph based workflows, suspend and resume, RAG and the ability to author MCP servers. Choose the Vercel AI SDK for a provider agnostic toolkit that fits Next.js, React, Svelte, Vue and Node. Choose Semantic Kernel for .NET, Python or Java teams; its README now points to Microsoft Agent Framework as the successor for new projects.

Where XERJ fits

XERJ works with every framework on this page. It is a new way for AI to search for data: a local search engine for agents, with a neurosymbolic model inside, that indexes files, code and docs and answers over MCP or an Elasticsearch compatible REST API. Your agent framework plans and calls tools; XERJ is the tool that finds the right passage with a citation. See agentic search and neurosymbolic AI.

How we checked

Stars, licences, main languages and latest release tags come from the GitHub API on 23 Nov 2026. Feature notes come from each project README, linked below, read the same day. We did not benchmark these frameworks for this page.

Read next

FAQ

What is the best alternative to LangChain in 2026?

It depends on the job. LlamaIndex and Haystack for RAG over documents, Pydantic AI or the OpenAI Agents SDK for small typed agents, CrewAI for teams of agents, DSPy for optimized prompts, and Mastra or the Vercel AI SDK for TypeScript.

Is LangGraph an alternative to LangChain?

LangGraph comes from the same team and works with or without LangChain. It is the lower level choice for long running, stateful agents, with durable execution and human in the loop.

What is the best LangChain alternative for RAG?

LlamaIndex and Haystack are built around retrieval and document pipelines. DSPy is a strong pick when you want to optimize a RAG pipeline against a metric.

Which LangChain alternatives are open source?

All frameworks on this page are open source: most are MIT, while Haystack, Mastra (outside its ee folders) and the Vercel AI SDK use Apache 2.0, per their licence files on 23 Nov 2026.

Can I use XERJ with these frameworks?

Yes. XERJ runs as an MCP server and a REST API, so any framework that can call a tool can search a XERJ index of your files, code and docs.

Evidence