In one line: LangChain is the most widely used LLM application framework. It abstracts the boilerplate of "calling models, calling tools, doing RAG, chaining steps, running agents" into uniform interfaces, so you write less glue and more business logic. Officially supported in Python and JS/TS.
What it is#
Without a framework you write: HTTP to OpenAI, parse response, hit vector DB, build prompt, call OpenAI again, parse… and every project rewrites it.
LangChain wraps these into composable components:
# Python LCEL syntax
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_template("Explain in one sentence: {topic}")
llm = ChatOpenAI(model="gpt-4o-mini")
chain = prompt | llm # pipe-compose
chain.invoke({"topic": "RAG"})The prompt | llm "LCEL expression" is the modern core abstraction — any component composes this way.
Analogy#
LangChain is like Express / FastAPI for web apps:
- Without a framework you can write HTTP, but every project re-implements routing / parsing / middleware.
- The framework absorbs that, so you focus on business logic.
Key concepts#
How it works#
Every component follows the same contract — mix and match to build RAG / agents / workflows.
Practical notes#
- Start from LCEL; don't use old Chain classes. Old
LLMChain/RetrievalQAare deprecated; new projects use LCEL only. - Move complex agents to LangGraph. LangChain suits linear + simple branching; multi-agent / long loops / state machines should use LangGraph directly.
- Use LangSmith. The free tier is enough for solo dev. Tracing speeds up prompt-debugging 5×.
- Don't lock yourself in. LangChain wraps things heavily — you can always drop to the OpenAI SDK directly. Mix tools as needed.
- TS version is near-parity. langchainjs works great for frontends / Next.js full-stack — you don't have to use Python.
Easy confusions#
Deeper at the data layer; lighter at the app layer.
Learning curve + opacity.
Each project writes more glue.
Further reading#
- LlamaIndex — RAG specialist in the same family
- LangGraph — same company; fits agent state graphs
- Docs: python.langchain.com / js.langchain.com