DEV Community

Cover image for LangChain vs 7 Alternatives: What Each One Installs and Sends (2026)
Moksh Gupta
Moksh Gupta

Posted on Originally published at devtoollab.com

LangChain vs 7 Alternatives: What Each One Installs and Sends (2026)

Under the hood, an LLM agent is a simple loop. You send the conversation and the tool schemas, run whichever tool the model asks for, and send the result back. A framework runs that loop for you. In return you take on its dependencies, its import time at cold start, and every release you have to keep up with.

There is a deadline here too. LangChain 0.3 is in maintenance only until December 2026, so code that still imports LLMChain has to move somewhere. On October 15, 2026, we installed LangChain and seven alternatives into clean environments on an M3 Pro MacBook Pro and ran one identical single-tool agent through each of them. LangChain pulled in 44 Python packages totaling 41.2 MB, compared with 14 packages and 18.1 MB for the plain OpenAI SDK. The requests the frameworks sent to the model were almost the same, except for one. This is a condensed version of the full write-up on DevToolLab, which includes the measurement script and runnable code for all eight frameworks.

LangChain 1.x fixed the churn, not the weight

LangChain 1.0 came out on October 17, 2025. It was rebuilt around create_agent, an agent loop that runs on LangGraph. Legacy chains, retrievers and the prompt hub moved into a separate langchain-classic package. The current release is 1.4.6. It is MIT licensed, had 147,856 GitHub stars on October 15, 2026, and the docs promise no breaking changes until 2.0.

LangChain homepage leading with LangSmith Engine above a strip of customer logos

The breaking changes have stopped. Three other problems remain:

  • Dependencies. langchain depends on langgraph, and langchain-core depends on langsmith, the client for LangChain's paid tracing product. Nothing goes to LangSmith unless LANGSMITH_TRACING=true is set, and our runs made no outbound calls, but the package gets installed either way.
  • Release pace. langchain-core put out 18 stable releases in the 90 days before October 15.
  • Business focus. The homepage now leads with LangSmith, whose Plus plan costs $39 per seat per month and includes 10,000 base traces a month.

This is the agent we rebuilt in every framework, written here in LangChain:

from langchain.agents import create_agent
from langchain_openai import ChatOpenAI


def get_weather(city: str) -> str:
    """Get the current weather for a US city."""
    return f"72 F and sunny in {city}"


model = ChatOpenAI(model="gpt-4o-mini", base_url="http://127.0.0.1:8765/v1", api_key="sk-test")
agent = create_agent(model, tools=[get_weather])
result = agent.invoke({"messages": [{"role": "user", "content": "What's the weather in Austin?"}]})
print(result["messages"][-1].content)
Enter fullscreen mode Exit fullscreen mode

LangChain's biggest advantage is still its integrations. Its docs cite "integrations to hundreds of LLMs and thousands of other integrations." If your only goal is to get off 0.3, upgrading to 1.x may be less work than switching frameworks.

Download counts, with a caveat

Download counts include CI runs and packages installed as dependencies of other packages, and that inflates LangChain's Python numbers. On npm the picture flips: ai gets roughly nine times as many downloads as langchain.

Package Registry Downloads, last 30 days
langchain PyPI 170.5M
pydantic-ai-slim PyPI 23.9M
openai-agents PyPI 12.4M
llama-index-core PyPI 6.6M
dspy PyPI 5.3M
haystack-ai PyPI 0.57M
ai (Vercel AI SDK) npm 126.5M
langchain npm 13.5M
@openai/agents npm 9.1M
@mastra/core npm 8.5M

PyPI numbers come from pypistats.org. npm numbers cover September 13 to October 12, 2026.

How the measurement worked

Every Python framework got a new uv environment on Python 3.13.0, and every TypeScript framework got a new npm project on Node 24.22.0 (arm64). Each one held only the packages needed to run an OpenAI-backed agent. For each environment we counted packages, added up their file sizes, and timed the agent's imports in CPU time, taking the best of 15 interleaved runs. We used CPU time because wall-clock times were unreliable with other jobs running on the laptop: the bare SDK's agent took anywhere from about 0.3 seconds to over 2.

framework                packages  size MB  import CPU ms
openai SDK only                14     18.1            201
LangChain                      44     41.2            463
Pydantic AI                    26     35.2            351
LlamaIndex                     67    118.0            718
Haystack                       42     59.6            368
DSPy                           66    187.4            328
OpenAI Agents SDK              38     43.8            544
openai SDK only (TS)            1     22.7             66
LangChain.js                   25     84.0            298
Vercel AI SDK                  12     22.5             57
Mastra                        154    116.6            263
OpenAI Agents SDK (TS)         25     66.6            187
Enter fullscreen mode Exit fullscreen mode

Next, each framework asked "What's the weather in Austin?" with a single get_weather tool. The requests went to a local server that mimics OpenAI's Chat Completions API and logs every request, so no API key or spend was involved. The measurement script and the exact code for all eight agents are in the original post. Remove base_url and api_key and the code runs against OpenAI.

Compared with the bare SDK, LangChain installs 3.1 times as many packages and uses 2.3 times as much CPU at import. On the wire the differences mostly disappear. Every framework that used native tool calling made two requests totaling 863 to 1,203 bytes. DSPy made three requests totaling 6,750 bytes. Logging DNS lookups showed two frameworks making network calls nobody asked for: DSPy downloaded a model price map from raw.githubusercontent.com, and the OpenAI Agents SDK sent traces to api.openai.com.

Pydantic AI: typed agents with a fast release cycle

Pydantic AI is the Python agent framework from the team that makes Pydantic. It is built around typed tools, typed outputs and dependency injection. Of the Python libraries here that still feel like a full framework, it has the smallest install, at 26 packages and 35.2 MB. It builds tool schemas from type hints and docstrings, and durable execution plugs into Temporal, DBOS, Prefect or Restate.

Pydantic AI landing page with the headline

The downside is how fast it moves. Version 2.0 came out June 23, 2026, about nine and a half months after 1.0. pydantic-ai-slim put out 56 stable releases in 90 days, more than three times as many as langchain-core. Our run also printed a banner advertising Logfire, Pydantic's paid observability service. Setting PYDANTIC_AI_NO_BANNER=1 turns it off.

License and version: MIT · 20,629 GitHub stars · v2.56.0 released October 13, 2026 · Python 3.11+

OpenAI Agents SDK: few primitives, tracing on by default

The OpenAI Agents SDK is the production successor to OpenAI's Swarm experiment, available in Python and TypeScript. It has a short list of building blocks: agents, handoffs, guardrails, and sessions for memory. @function_tool turns a plain Python function into a tool. Tracing and MCP tool calling are included in the 38-package install.

There are two drawbacks. It is still below 1.0, at version 0.24.0 after 88 stable releases in a year. Tracing is also on by default: unless you call set_tracing_disabled(True), it sends traces to api.openai.com, which is what our run did. Non-OpenAI models work through OpenAI-compatible Chat Completions endpoints or through the beta Any-LLM and LiteLLM adapters.

License and version: MIT · 30,051 GitHub stars · openai-agents 0.24.0 released October 15, 2026 · @openai/agents 0.20.0 for TypeScript

LlamaIndex: built for retrieval, now Python only

LlamaIndex calls its framework "our original open-source toolkit for RAG and agents," and the company now leads with LlamaParse, its hosted document parser. It's a big install. Our one-tool agent needed 67 packages and 118 MB, including NLTK and NumPy, and it had the slowest Python import we measured at 718 ms. It's also Python only now: LlamaIndex.TS was archived on April 30, 2026, and the core library is still below 1.0.

What you get for that weight is the data layer. Connectors, indexes, query engines and event-driven Workflows are all built in, and LlamaParse output loads straight into an index your agent can query.

License and version: MIT · 52,507 GitHub stars · llama-index-core 0.14.25 released September 21, 2026

Haystack: pipelines you can save as YAML

Haystack, from deepset, builds applications as explicit pipelines. Each component has typed inputs and outputs, and the resulting graph can be saved to YAML and loaded back. It is built for production RAG that behaves predictably. When a pipeline is saved, API keys are stored as environment variable names rather than the keys themselves. Hayhooks can serve any pipeline as a REST endpoint or an MCP server. The install is 42 packages and 59.6 MB.

Major versions still require migration work. Haystack 3.0, released July 20, 2026, removed ToolInvoker and the legacy generators. The docs also say Haystack sends anonymous usage statistics unless HAYSTACK_TELEMETRY_ENABLED=False is set, though our agent run made no outbound calls.

License and version: Apache-2.0 · 26,745 GitHub stars · v3.4.0 released October 15, 2026 · Python 3.11+

DSPy: signatures instead of prompts

DSPy, from Stanford NLP, describes itself as a way to program language models rather than prompt them. You declare inputs and outputs as a signature, and optimizers such as GEPA and MIPROv2 tune the prompts against a metric you define. None of the other frameworks here do that. Give DSPy labeled examples and a metric, and it rewrites the prompts and few-shot examples itself.

DSPy docs homepage reading

import dspy


def get_weather(city: str) -> str:
    """Get the current weather for a US city."""
    return f"72 F and sunny in {city}"


dspy.configure(lm=dspy.LM("openai/gpt-4o-mini", api_base="http://127.0.0.1:8765/v1",
                          api_key="sk-test", cache=False))
agent = dspy.ReAct("question -> answer", tools=[get_weather])
print(agent(question="What's the weather in Austin?").answer)
Enter fullscreen mode Exit fullscreen mode

DSPy is also the reason the request sizes differ. It had the largest install by size, 187.4 MB across 66 packages. Its default ChatAdapter sets use_native_function_calling=False, so ReAct writes its own field format into the prompt instead of using the model's tool calling. That is how one weather question grew to 6,750 bytes over three requests. On the first call it also downloads LiteLLM's model price map, unless LITELLM_LOCAL_MODEL_COST_MAP=True is set.

License and version: MIT · 38,644 GitHub stars · v3.4.1 released October 12, 2026

Vercel AI SDK: the lightest framework we measured

The Vercel AI SDK describes itself as "the TypeScript toolkit for building AI applications and agents." It gives you generateText, a ToolLoopAgent class, model providers as separate packages, and UI hooks such as useChat. It is nearly free to add: 12 packages, 22.5 MB and a 57 ms import, about the same as the bare openai package, and it still runs the tool loop for you.

AI SDK homepage with the headline

import { generateText, stepCountIs, tool } from "ai";
import { createOpenAI } from "@ai-sdk/openai";
import { z } from "zod";

const openai = createOpenAI({ baseURL: "http://127.0.0.1:8765/v1", apiKey: "sk-test" });
const { text } = await generateText({
  model: openai.chat("gpt-4o-mini"),
  tools: {
    get_weather: tool({
      description: "Get the current weather for a US city.",
      inputSchema: z.object({ city: z.string() }),
      execute: async ({ city }) => `72 F and sunny in ${city}`,
    }),
  },
  stopWhen: stepCountIs(5),
  prompt: "What's the weather in Austin?",
});
console.log(text);
Enter fullscreen mode Exit fullscreen mode

The cost is frequent major versions. Version 5.0 came out July 31, 2025, 6.0 on December 22, 2025, and 7.0 on June 25, 2026. Each had a migration guide and codemods (npx @ai-sdk/codemod v7 for the latest). Durable workflows need the separate @ai-sdk/workflow package, and you have to build memory and evals yourself.

License and version: Apache-2.0 · 27,327 GitHub stars · ai 7.0.141 published October 15, 2026

Mastra: agents, workflows and memory in one package

Mastra is a TypeScript framework that covers agents, suspendable workflows, memory and evals, and it comes with a local Studio UI for testing them. All of that makes it heavy: @mastra/core installed 154 packages and 116.6 MB, the largest TypeScript install we measured. Not all of it is open source either. Code in ee/ directories needs a Mastra Enterprise License to run in production, and the hosted Teams plan is $250 a month.

In return, you get the pieces the AI SDK leaves out. Its model router accepts a string ID for any of more than 8,200 models from 218 providers, and mastra dev starts Studio on your machine.

License and version: Apache-2.0 core plus Mastra Enterprise License · 28,831 GitHub stars · @mastra/core 1.77.0 published October 14, 2026

The whole table

Framework Language Packages Install size Import CPU Bytes sent License
OpenAI SDK only Python 14 18.1 MB 201 ms 863 Apache-2.0
LangChain 1.4.6 Python 44 41.2 MB 463 ms 893 MIT
Pydantic AI 2.56.0 Python 26 35.2 MB 351 ms 1,021 MIT
OpenAI Agents SDK 0.24.0 Python 38 43.8 MB 544 ms 1,033 MIT
LlamaIndex 0.14.25 Python 67 118.0 MB 718 ms 1,203 MIT
Haystack 3.4.0 Python 42 59.6 MB 368 ms 890 Apache-2.0
DSPy 3.4.1 Python 66 187.4 MB 328 ms 6,750 MIT
LangChain.js 1.5.16 TypeScript 25 84.0 MB 298 ms 1,098 MIT
Vercel AI SDK 7.0.141 TypeScript 12 22.5 MB 57 ms 1,066 Apache-2.0
Mastra 1.77.0 TypeScript 154 116.6 MB 263 ms 1,181 Apache-2.0 + EE

Measured on one M3 Pro laptop on October 15, 2026. "Bytes sent" is the total of every request made to answer the Austin question.

Choosing one without migrating twice

  1. Check what you actually import. If your code is mostly langchain.chains and LLMChain, you have to migrate before December 2026 whatever you choose. If it only uses chat models and tools, porting to any of these is a small job.
  2. Measure your own dependency list. Add your vector store and model providers, then compare import times wherever cold starts matter, such as AWS Lambda in us-east-1. The PyPI Package Inspector shows a framework's dependency tree and release history, and the NPM Package Size Checker estimates what ai or @mastra/core adds to your bundle.
  3. Decide where your traces should go. LangSmith, Pydantic Logfire and OpenAI's trace viewer each tie you to a vendor. Check every default that makes network calls.
  4. Expect churn from all of them. Pydantic AI and the AI SDK both shipped more releases than LangChain this year. Pin exact versions.
  5. Port one agent first. Rebuild your smallest real agent behind a logging proxy and compare the requests and byte counts before you move anything else.

What we'd pick

  • Python with typed outputs and fewer layers: Pydantic AI, pinned to an exact version.
  • Only OpenAI models: the OpenAI Agents SDK, with tracing turned off if data can't leave your network.
  • Mostly retrieval over messy documents: LlamaIndex.
  • Pipelines that get code-reviewed before production: Haystack.
  • You have labeled examples and a metric: DSPy.
  • TypeScript and Next.js: the Vercel AI SDK, or Mastra if you want workflows, memory and a local UI included.
  • You just need to get off 0.3: stay on LangChain and upgrade to 1.x.

Wrapping up

LangChain 1.0 stopped the breaking changes, but even the smallest agent now pulls in LangGraph and the LangSmith client. Apart from DSPy, every framework sent the model essentially the same request. The real differences are in what they install, which network calls they make on their own, and how often they break your code. Measure them against your own stack before you start porting.

References

Top comments (0)