LangChain Inc.
Composable building blocks for LLM apps — chains, agents, retrievers, and integrations.
GitHub Stars
137.0K
Contributors
3.7K
npm / Week
2.2M
PyPI / Month
241.8M
LangChain is the most widely adopted framework for building LLM-powered applications and agents. Maintained by LangChain Inc., it was first released in 2022 under the MIT license and is available as a mixed (polyglot) library with mature Python and TypeScript SDKs. With over 136,000 GitHub stars, 3,600+ contributors, and more than 240 million monthly downloads on PyPI, it dominates the ecosystem as the default starting point for teams building retrieval-augmented generation (RAG) pipelines, tool-using agents, and multi-step LLM workflows.
LangChain solves a fundamental problem: connecting LLMs to the rest of your stack. It provides a unified interface for hundreds of model providers, vector stores, retrievers, and external tools, letting developers compose these components without rewriting glue code for each integration. The framework is opinionated about modularity but flexible enough to accommodate everything from a single chain to a heterogeneous multi-agent system. Its design philosophy prioritizes composability and rapid prototyping, making it the go-to choice for teams that need to move fast and iterate on LLM application logic.
LangChain is code-first and declarative by default, though it supports imperative control flow when needed. The core abstractions are:
LCEL is the framework’s declarative composition layer. You pipe components together using | (similar to Unix pipes) to define a processing pipeline. For example, a RAG chain might look like: retriever | prompt | model | output_parser. This approach makes the data flow explicit and easy to debug. For more complex agent logic (branching, loops, human-in-the-loop), LangChain provides an agent executor that runs a tool-calling loop until a stop condition is met.
Control flow is largely deterministic in chains and probabilistic in agents (the LLM decides the next step). LangChain handles the orchestration of tool calls, error handling, and retries. The framework also supports streaming at the model and chain level, so you can stream tokens as they are generated.
LangChain ships a massive integration surface. Out of the box, it supports hundreds of model providers, vector stores, document loaders, text splitters, and tools. This is its strongest differentiator: you rarely need to write a custom wrapper.
LCEL composition lets you build pipelines declaratively. It is not just syntactic sugar; LCEL includes built-in support for streaming, async execution, and batch processing. You can also attach callbacks for logging and tracing.
LangSmith integration is first-class. LangSmith provides observability, evaluation, and debugging for LangChain applications. You can trace every step of a chain or agent, annotate runs, run LLM-as-judge evals, and compare iterations. This closes the development loop: prototype in LangChain, observe in LangSmith, iterate.
Confirmed capabilities include:
Where it excels: Rapid prototyping of RAG pipelines, heterogeneous model routing (switch between providers with one line of code), and building standard tool-calling agents. The framework is battle-tested in production by thousands of teams.
Teams deploy LangChain primarily for three workload types:
LangChain is a poor fit for highly complex, long-running agent workflows with nested subgraphs, persistent state, and fine-grained control over execution. For those, the maintainers recommend LangGraphcars. It also struggles with extremely low-latency requirements if you need to avoid the overhead of LCEL’s abstraction layer.
Install LangChain for Python:
1pip install langchain
For TypeScript/Node.js:
1npm install @langchain/core @langchain/community
The smallest meaningful example (Python):
1from langchain.chat_models import init_chat_model2from langchain_core.messages import HumanMessage34model = init_chat_model("openai:gpt-4o")5response = model.invoke([HumanMessage("Hello, world!")])6print(response.content)
To build a RAG pipeline, you will need:
Start with the official docs at [python.langchain.com](https://python.langchain.com) or [js.langchain.com](https://js.langchain.com). The community is large and active on GitHub Discussions, Discord, and X (@langchain_oss).
LangChain vs. LangGraph: LangChain is the higher-level framework for quick prototyping. LangGraph is the low-level orchestration framework from the same team, designed for production-grade agent workflows with persistent state, branching, and human-in-the-loop. If you need full control over agent execution, use LangGraph. If you want to build a simple chain or agent in minutes, start with LangChain.
LangChain vs. CrewAI: CrewAI focuses on multi-agent collaboration with role-based agents and tasks. LangChain is more general-purpose; it gives you the primitives to build multi-agent systems but does not prescribe a specific collaboration model. Choose CrewAI if you want a opinionated multi-agent framework out of the box. Choose LangChain if you need maximum flexibility and a larger integration ecosystem.
LangChain vs. LlamaIndex: LlamaIndex specializes in data indexing and retrieval for RAG. LangChain also does RAG well, but its strength is broader LLM application composition. If your primary workload is advanced indexing, chunking, and querying over structured/unstructured data, LlamaIndex may be a better fit. If you need to combine RAG with tool use, agents, and multi-model routing, LangChain is the more complete choice.
When to choose LangChain: You are prototyping an LLM feature, building a RAG system with multiple data sources, or need to switch between model providers without rewriting code. Its vast integration surface and mature community make it the safest bet for most teams starting out.
When to avoid LangChain: You need fine-grained control over agent loop internals, or you are building a high-throughput system where every millisecond of overhead matters. In those cases, consider LangGraph or a custom solution with a minimal abstraction layer.
What the framework gives you out of the box, in plain language.
Hundreds of model providers, vector stores, retrievers, and tools out of the box.
LangChain Expression Language for declarative pipeline composition.
First-class observability and evaluation with LangSmith.
The jobs this framework is best suited for.
Retrieval-augmented generation with one of the largest catalogues of vector stores.
Wire models, retrievers, and tools together in a few lines of code.
Switch between providers behind a uniform interface.
Side-by-Side
Add a second or third framework and see stars, downloads, and capabilities lined up next to each other.
Close alternatives worth a look before you decide.
Stateful, graph-based agent workflows with first-class human-in-the-loop.
Complex, stateful agent graphs
Stars
32.3K
npm / wk
—
PyPI / mo
49.0M
Multi-agent crews with role-based prompts and explicit task hand-offs.
Role-based multi-agent crews
Stars
51.6K
npm / wk
—
PyPI / mo
9.6M
Data-grounded agents and RAG pipelines, with deep indexing primitives.
Data-grounded RAG agents
Stars
49.5K
npm / wk
—
PyPI / mo
11.6M