---
title: "LangChain alternatives 2026: 10 frameworks for agents and RAG"
canonical: "https://xerj.org/compare/langchain-alternatives-2026"
updated: "2026-11-23"
---

# LangChain alternatives in 2026: 10 frameworks for agents and RAG

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.

## Agent prompt

```text
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

- RAG over your documents: **LlamaIndex** or **Haystack**.
- Long running, stateful agents, same team as LangChain: **LangGraph**.
- Small typed Python agents: **Pydantic AI** or the **OpenAI Agents SDK**.
- A team of agents with roles: **CrewAI**.
- Better prompts by optimization: **DSPy**.
- TypeScript: **Mastra** or the **Vercel AI SDK**.
- .NET or Java: **Semantic Kernel**.
- Search for any of them: **XERJ** over MCP.

## 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](https://xerj.org/science/agentic-search) and [neurosymbolic AI](https://xerj.org/science/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

- [What is agentic search?](https://xerj.org/science/agentic-search)
- [Best MCP server for local code search 2026](https://xerj.org/compare/best-mcp-server-local-code-search-2026)
- [Best MCP memory servers for Claude Code 2026](https://xerj.org/compare/best-mcp-memory-servers-claude-code-2026)
- [Mem0 alternatives 2026](https://xerj.org/compare/mem0-alternatives-2026)
- [Best reranker models 2026](https://xerj.org/compare/best-reranker-models-2026)
- [All comparisons](https://xerj.org/compare/)

## 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

- LangChain: [github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)
- LangGraph README: [github.com/langchain-ai/langgraph](https://github.com/langchain-ai/langgraph)
- LlamaIndex README: [github.com/run-llama/llama_index](https://github.com/run-llama/llama_index)
- Haystack README: [github.com/deepset-ai/haystack](https://github.com/deepset-ai/haystack)
- DSPy README: [github.com/stanfordnlp/dspy](https://github.com/stanfordnlp/dspy)
- CrewAI README: [github.com/crewAIInc/crewAI](https://github.com/crewAIInc/crewAI)
- Pydantic AI README: [github.com/pydantic/pydantic-ai](https://github.com/pydantic/pydantic-ai)
- OpenAI Agents SDK README: [github.com/openai/openai-agents-python](https://github.com/openai/openai-agents-python)
- Semantic Kernel README: [github.com/microsoft/semantic-kernel](https://github.com/microsoft/semantic-kernel)
- Mastra README and licence: [github.com/mastra-ai/mastra](https://github.com/mastra-ai/mastra)
- Vercel AI SDK README and licence: [github.com/vercel/ai](https://github.com/vercel/ai)
- GitHub API stars, licences, languages and releases, 23 Nov 2026.
