Python + LangChain
LLM application orchestration in Python with LangChain and LangGraph: retrieval, tool calling and agents over hosted or self-hosted models.
- Python
- LangChain
- Pydantic
- Learning curve
- Moderate
- Status
- Actively developed
- Reviewed
- November 2026
- Best for
- Retrieval-augmented generation over internal documents
- Tool-calling agents with multi-step, stateful workflows (via LangGraph)
- Products that need to switch or mix LLM providers
- Prototyping LLM features quickly with ready-made integrations
- Not ideal for
- Training or fine-tuning models
- Single summarisation or classification call
Overview
LangChain is a Python framework for building applications on top of large language models: chat models from many providers behind one interface, plus tools, retrievers, document loaders and vector-store integrations. It is split into packages: langchain-core for shared abstractions, provider packages such as langchain-openai and langchain-anthropic, langchain for high-level agents, and LangGraph for stateful, multi-step workflows. Teams reach for it to build RAG systems and tool-using agents without writing every integration by hand; it does not train or host models.
What's inside
A first RAG app is quick for Python developers. The harder parts are LangChain's many abstractions and changing APIs, LangGraph's state and checkpoint model, and LLM-specific skills: prompt design, retrieval tuning and evaluation.
Python
Language
The language the code is written in
Learning: Easy
Status: Active
LangChain
Other
Supporting tool
Learning: Moderate
Status: Active
Pydantic
Other
Supporting tool
Learning: Easy
Status: Active
How it works
Application code assembles a chain or a LangGraph graph from chat models, prompts, retrievers and tools. At run time each step calls an LLM provider or a data source, passes structured messages along, and a checkpointer persists state between steps.
- 1.
Language to other
Python code defines tools as typed functions and structured outputs as Pydantic models, which LangChain converts into the JSON schemas chat models use for tool calling.
- 2.
Other to database
For retrieval, documents are loaded, split into chunks, embedded and stored in a vector store such as pgvector or Chroma; at query time a retriever fetches the most relevant chunks.
- 3.
Other to backend
A chat model integration sends the prompt, retrieved context and tool schemas to the provider's API (or a local Ollama or vLLM server) and streams the response back.
- 4.
Other to other
LangGraph runs the agent loop as a state graph: nodes call the model or execute requested tools, edges choose the next step, and a checkpointer (SQLite or Postgres) saves state for resumption and human approval.
- 5.
Other to infrastructure
Traces of every model and tool call go to LangSmith or another tracing tool such as Langfuse for debugging, cost tracking and evaluation.
Strengths and drawbacks
Strengths
Provider-agnostic model interface
Chat models, embeddings and tool calling share one interface across providers, so moving between OpenAI, Anthropic, Google or a local Ollama model is mostly configuration, not a rewrite.
Large integration catalogue
Document loaders, text splitters, vector stores and retrievers exist for most databases and file formats, which shortens RAG prototypes considerably.
LangGraph for controllable agents
Explicit state graphs with checkpointing, interrupts for human approval, retries and streaming of intermediate steps give far more control than a free-running agent loop.
Tracing and evaluation
LangSmith integration records every prompt, tool call and token count, and supports datasets and evaluators for regression-testing prompts and agents.
Drawbacks
Abstraction overhead
Layers of runnables, callbacks and integration wrappers can hide what prompt is actually sent; for a single well-defined LLM call, the provider's own SDK is often clearer.
History of API churn
The project went through several breaking reorganisations on the way to 1.0, with legacy chains moved out of the main package, so older tutorials and samples often no longer run.
Uneven integration quality
Community integrations vary widely in maintenance and test coverage; pin versions and prefer the first-party provider packages.
Model costs and nondeterminism dominate
Latency, rate limits, token spend and inconsistent outputs come from the models; production use needs caching, timeouts, fallbacks and evaluation suites regardless of framework.
Scores
Editorial ratings out of 10, comparable across every stack in the guide. They are judgement, not benchmarks. How we score
- Speed of building
- 8.4 out of 10, catalog average 7.7
- Ease of learning
- 7.0 out of 10, catalog average 7.2
- Scalability
- 6.4 out of 10, catalog average 7.6
- Performance
- 5.8 out of 10, catalog average 7.5
- Maintainability
- 5.0 out of 10, catalog average 7.2
- Ecosystem
- 8.4 out of 10, catalog average 8.2
- Flexibility
- 8.0 out of 10, catalog average 7.4
How quickly a team ships features
Higher means easier to pick up
How far it grows before a redesign
Speed of the running application
How well the codebase ages
Libraries, hosting, docs and hiring
How many kinds of product it suits
How it scales
LangChain code is an application layer that scales like any Python service; the real limits are provider rate limits, model latency, token cost and vector-store performance.
- Starting outMVP and first users
- A script or notebook calling a hosted model, with a local Chroma or FAISS index over a few thousand documents.
- GrowingReal traffic, a few engineers
- A FastAPI service exposing a LangGraph agent with streaming responses, Postgres with pgvector for retrieval and checkpoints, and LangSmith or Langfuse tracing.
- LargeHeavy traffic or data
- Horizontally scaled stateless workers with persisted graph state, response caching, provider fallbacks and per-tenant rate limits, plus offline evaluation runs on every prompt change.
- EnterpriseMany teams and regions
- A central LLM gateway enforcing keys, quotas and PII redaction, several agent services sharing retrieval infrastructure, and governance over which models and data sources each application may use.
Where it fits
Common projects, from best fit to worst.
Internal knowledge-base assistant (RAG)
Loaders, splitters, embeddings and retrievers cover ingestion and search, and tracing shows which chunks led to each answer.
Great fit
Multi-step operations agent with human approval
LangGraph checkpoints and interrupts let a person approve refunds or changes; reliability still depends on careful tool design and evaluations.
Good fit
Single summarisation or classification call
A direct provider SDK call with a Pydantic schema is simpler, has fewer dependencies and is easier to debug.
Poor fit
Training or fine-tuning models
LangChain has no training functionality; use PyTorch or Hugging Face Transformers.
Avoid
Alternatives
Similar stacks, and when you would choose them instead.
- Python + Hugging Face Transformers
Choose it when you need to fine-tune or run open-weight models yourself; LangChain only orchestrates calls to models.
ComparePython + LangChain with Python + Hugging Face Transformers - FastAPI + PostgreSQL
Choose a plain FastAPI service calling a provider SDK directly when the feature is one or two well-defined LLM calls and extra abstraction is not worth it.
ComparePython + LangChain with FastAPI + PostgreSQL
Sources
Reviewed on November 19, 2026 against the documentation below. Found something out of date? Suggest a correction. Read our methodology.
- LangChain documentation
Official docs for LangChain, LangGraph and LangSmith.
- LangChain on GitHub
Source for langchain, langchain-core and first-party provider packages.
- LangGraph on GitHub
Source for the stateful agent orchestration library.
- Pydantic documentation
Used for tool argument schemas and structured model output.
Related stacks
Stacks that share technologies with Python + LangChain.
Python + FastAPI + PyTorch
PyTorch models served behind a FastAPI HTTP API, a common pattern for custom, small-to-medium scale model inference services.
- Python
- FastAPI
- Pydantic
- +1
Learning: Moderate
FastAPI + SQLAlchemy + PostgreSQL
FastAPI with the SQLAlchemy 2.0 ORM, Alembic migrations and PostgreSQL, the Python API stack for teams that want a full unit-of-work ORM behind typed endpoints.
- FastAPI
- SQLAlchemy
- PostgreSQL
- +2
Learning: Moderate
Python + PyTorch
PyTorch on Python, the most widely used deep-learning stack for research, model training and fine-tuning.
- Python
- PyTorch
Learning: Hard