LangChain: The Framework for Orchestrating LLM Applications
Table of contents
- Key takeaways
- What It Includes
- A Minimal RAG Example
- Patterns Where It Truly Adds Value
- Frequent (Justified) Criticism
- Alternatives and Different Philosophies
- When to Use Each Option
- Conclusion
- Frequently asked questions
- LangChain or LlamaIndex: which one to choose?
- Does LangChain work with local models like Ollama?
- What is the lightest alternative to LangChain for production?
Actualizado: 2026-05-03
LangChain[1] is probably the most adopted framework for building LLM applications. Its proposition: instead of making direct OpenAI API calls and assembling your own plumbing, use a coherent set of abstractions to compose complex pipelines. We cover when it adds real value, when it adds unnecessary complexity, and the components worth knowing.
Key takeaways
- LangChain is a superset: LLM wrappers, prompt templates, chains, retrievers, agents, memory, and document loaders in a coherent interface.
- It shines in prototypes, multi-LLM orchestration, and junior teams — where uniformity and exploration speed matter more than optimisation.
- Its criticisms are fair: unstable API between minor versions, abstractions that hide what’s happening beneath, and performance penalties in production at scale.
- For single well-defined production use cases, direct code usually wins on maintainability.
- LlamaIndex, Instructor, and direct calls are reasonable alternatives for specific cases.
What It Includes
LangChain is a superset of features. Main areas:
- LLM wrappers: uniform interface over OpenAI, Anthropic, local models (Llama 2, Mistral), Hugging Face, etc.
- Prompts and prompt templates: management of reusable templates with variables, few-shot examples, and composition.
- Chains: sequences of steps. The simplest binds a prompt template to an LLM. Complex ones orchestrate retrieval, validation, and multiple calls.
- Retrievers: abstraction over vector DBs (Chroma, Pinecone, Qdrant, pgvector) with consistent interface.
- Agents: “decide + act” loops based on function calling or the ReAct pattern.
- Memory: conversation history management with various strategies (buffer, summary, window).
- Document loaders: readers for PDF, web, Notion, Slack, database, Google Drive, and dozens more.
- Output parsers: validation and conversion of LLM output to structured types.
This breadth is both its strength and most frequent criticism.
A Minimal RAG Example
What was 100 lines of direct code reduces to this:
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.document_loaders import TextLoader
from langchain.chains import RetrievalQA
from langchain.chat_models import ChatOpenAI
docs = TextLoader("manual.txt").load()
splits = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50).split_documents(docs)
db = Chroma.from_documents(splits, OpenAIEmbeddings())
qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(), retriever=db.as_retriever())
print(qa.run("What does the manual say about warranty?"))Load document, split into chunks, embed, index, configure retriever, connect to LLM, expose question-answering function — all in eight operative lines. Prototyping speed is real.
Patterns Where It Truly Adds Value
Three cases where LangChain is the right choice:
- Prototypes and exploration. When validating an idea, getting to a demo fast matters more than having optimal code.
- Orchestrating multiple LLMs and tools. If your system combines OpenAI, Anthropic, web search, internal DB, and conversational memory, LangChain already has each piece with a consistent interface.
- Junior teams with LLMs. Abstractions reduce the space of common errors (prompt format, token management, output parsing).
Frequent (Justified) Criticism
LangChain has received serious criticism worth knowing:
- Too much abstraction. For simple cases, it hides what’s actually happening under layers. Debugging gets hard when something fails — you need to understand the abstraction and what’s beneath.
- Unstable API. Incompatible changes between minor versions. Code from three months ago may not compile today.
- Over-engineering. Some abstractions seem designed to impress more than to solve real problems (chains of chains of chains).
- Performance penalty. Python layer over HTTP calls adds latency. For production at scale, coding closer to the metal may pay off.
- Volatile documentation. The library evolves so fast that public tutorials and blogs are constantly outdated.
In response, a “LangChain too much for me” current has emerged — teams preferring direct code. For serious production, that criticism is legitimate.
Alternatives and Different Philosophies
If LangChain feels heavy, there are options:
- LlamaIndex[2]: specific focus on RAG and document indexing, less pretense of “universal framework”. Simpler if your case is retrieval.
- Instructor[3]: for structured extraction with Pydantic. Much simpler if that’s all you need.
- Direct calls + small utilities. For many production products it’s the more maintainable option: openai-python + your logic + your favourite vector DB.
- Semantic Kernel[4] by Microsoft. More aligned with .NET but Python available.
The right choice depends on how much of the framework you actually need and how much magic you tolerate underneath. The same criteria you’d apply when comparing text embeddings — start simple, measure, migrate when it makes sense.
When to Use Each Option
- Prototypes, hackathons, exploration: LangChain. Saves hours of plumbing.
- Production of a single well-defined use case: very likely direct code. Maintainability beats initial speed.
- Product with multiple LLM flows, multiple integrations, large team: LangChain or equivalent. Uniformity matters.
- If LangChain blocks you on performance or opacity: migrate to direct code or LlamaIndex in critical modules. Migration isn’t traumatic if your business logic is well separated.
Conclusion
LangChain is a valuable framework that has accelerated the LLM ecosystem’s maturation. Its criticisms are fair but so is its usefulness. The key is applying it where its abstractions add more than they hide. For serious products, knowing it is useful even if you eventually decide not to use it — understanding its patterns will tell you what needs to be in your code.
Frequently asked questions
LangChain or LlamaIndex: which one to choose?
LangChain is better suited for building agents and complex processing chains. LlamaIndex is optimized for document indexing and retrieval (RAG). For projects combining both needs, many teams use LlamaIndex for the retrieval layer and LangChain for orchestration.
Does LangChain work with local models like Ollama?
Yes. LangChain has native integration with Ollama through langchain-community. You can use any Ollama model as an LLM or embeddings model within your chains.
What is the lightest alternative to LangChain for production?
Many teams prefer using official SDKs directly (OpenAI, Anthropic) without extra abstractions, or lightweight frameworks like instructor for structured outputs. LangChain adds power but also complexity and dependencies.