You can call an LLM in one line โ send text, get text back. So why does LangChain exist? Because real apps need more than one message: they need memory, documents, tools, and multiple steps chained together. LangChain is the toolkit that wires all of that together so you don't rebuild it every time.
The one-sentence definition
LangChain is a Python (and JavaScript) framework for building apps powered by large language models โ chatbots, document Q&A, and agents โ by giving you reusable building blocks: models, prompts, chains, memory, retrievers, and tools. Think of it as the "Express.js of LLM apps": you could do it by hand, but the framework saves you from reinventing plumbing.
Install and say hello
Install LangChain and one provider package. The examples in this series use init_chat_model, which lets you swap providers with a single string โ Claude, OpenAI, Gemini, or a local model.
pip install langchain langchain-anthropic # set your key: export ANTHROPIC_API_KEY=sk-...
from langchain.chat_models import init_chat_model
# swap "anthropic"/"claude-opus-5" for "openai"/"gpt-4o-mini",
# "google_genai"/"gemini-1.5-flash", etc. โ the rest never changes
model = init_chat_model("claude-opus-5", model_provider="anthropic")
reply = model.invoke("Explain recursion to a first-year CSE student in 2 lines.")
print(reply.content)That .invoke() method is the heartbeat of LangChain โ every building block, from a single model to a 10-step agent, is called the same way.
What LangChain actually gives you
- A unified interface โ the same code runs on any provider. Switching from OpenAI to Claude is a one-line change, not a rewrite.
- Prompt templates โ reusable, variable-filled prompts instead of messy f-strings (next post).
- Chains (LCEL) โ pipe steps together with the
|operator (the chains guide). - Memory, retrieval (RAG), tools, and agents โ the pieces that turn a toy script into a real product.
The mental model for this whole series
Everything in LangChain is a Runnable โ a thing with an .invoke() method. Models are Runnables. Prompts are Runnables. Chains are Runnables made of other Runnables. Once that clicks, the whole framework feels like one idea repeated. We'll build up from a single call to a full LangGraph agent across the next nine posts.
Next: the core concepts โ models, prompt templates, and output parsers. Prefer to learn the models themselves first? Start with our free AI course.
โ All Articles