Compose unified interfaces for language models, embeddings, and prompts while building multi-step applications through chains, memory, retrieval, and agents. Master LangChain's six core pillars to orchestrate complex LLM workflows that retrieve data, remember context, invoke tools, and reason across steps.
LangChain is an open-source framework — available in both Python and JavaScript/TypeScript — designed to help developers build applications powered by large language models (LLMs). At its core, LangChain addresses a simple but critical observation: calling an LLM in isolation is rarely enough for a real-world application. Useful products need to retrieve relevant data, remember past interactions, invoke external tools, and coordinate multi-step reasoning. LangChain provides a structured set of abstractions and composable components to wire all of these concerns together in a maintainable way.
Think of LangChain as the "plumbing" layer between your application logic and the raw intelligence of an LLM. Just as a web framework like Flask or Express gives you routing, middleware, and request handling so you don't have to build those from scratch, LangChain gives you prompts, chains, memory, retrievers, and agents so you don't have to reinvent LLM orchestration every time.
LLMs are stateless text-in / text-out functions. By themselves, they cannot:
Every team building serious LLM applications ends up solving these problems independently, and solving them well requires careful engineering. LangChain consolidates those solutions into a reusable, tested, and extensible library so that teams can focus on what makes their application unique.
LangChain organises its functionality around six tightly related areas. Understanding how they fit together is the key to understanding the framework.
The six core pillars of LangChain and how they orbit the central framework. Each pillar is an independently usable module that can be combined with the others.
The foundation of everything. LangChain provides unified interfaces for LLMs (text-in / text-out), Chat Models (message lists in / message out), and Embedding Models (text-in / vector out). Because it wraps providers like OpenAI, Anthropic, Google, Cohere, and local models behind a common interface, you can swap providers without rewriting your application logic.
Prompts are managed through prompt templates — parameterised string blueprints that keep instructions separate from runtime data, making prompts reusable, testable, and version-controllable.
A chain is a sequence of steps where the output of one step feeds into the next. The simplest chain is prompt → model → output parser. More complex chains branch, loop, or call sub-chains. LangChain's LangChain Expression Language (LCEL) — using a pipe (|) operator — makes composing these steps concise and readable:
chain = prompt | model | output_parser
result = chain.invoke({"topic": "black holes"})
Chains are the primary unit of composition in LangChain, and almost every other feature is expressed as a chain or a component within one.
Because LLMs are stateless, memory components give chains the ability to persist and recall information across multiple calls. Simple buffer memory stores the raw conversation history; more advanced strategies summarise old turns or select only the most relevant ones to stay within the context window. Memory can be stored in-process (in RAM) or in external backends like Redis or a database.
RAG is the pattern of grounding an LLM's response in external documents retrieved at query time. LangChain provides:
This pillar is what enables LLM applications to answer questions about private or up-to-date information the model was never trained on.
Tools are functions an LLM can choose to call — a web search, a calculator, a database query, a code interpreter. Agents wrap an LLM in a reasoning loop: the model decides which tool to call, calls it, observes the result, and repeats until it reaches an answer. This transforms the LLM from a passive text generator into an active problem-solver that can interact with the world.
LCEL is LangChain's declarative interface for composing chains. Every LCEL object implements a common Runnable interface with methods like .invoke(), .stream(), and .batch(). This uniformity means any component — a prompt, a model, a retriever, a custom function — can be composed with any other using the | operator, and the resulting chain automatically supports streaming, async execution, and parallel branches.
A realistic LangChain application combines all six pillars. Consider a customer-support chatbot that answers questions about a company's product documentation:
The entire pipeline is wired together as an LCEL chain, giving it built-in support for streaming tokens to the user as they are generated.
LangChain itself focuses on composable building blocks. Two companion projects extend it:
Together, these three projects cover the full lifecycle of an LLM application: development (LangChain), orchestration of complex agents (LangGraph), and observability (LangSmith).
Because LangChain is a framework of composable parts, the best way to learn it is to understand each pillar in depth before combining them. A natural progression is:
Each subsequent concept in this course corresponds to one of these pillars or a specific technique within them. By the end, you will have a complete mental model of how LangChain's abstractions fit together and how to apply them to build reliable, production-grade LLM applications.