LangChain is a comprehensive framework for building applications powered by large language models (LLMs), transforming simple prompts into production-ready AI agents. With the v1.0 release in October 2025, it has been streamlined around three pillars: create_agent (the new standard agent builder), middleware (composable hooks for customization), and standard content blocks (provider-agnostic message content). LangChain abstracts the complexity of chaining LLM calls, managing memory, integrating tools, and orchestrating retrieval-augmented generation (RAG) pipelines, while LangGraph (stateful graph workflows) and LangSmith (observability) complete the ecosystem. A critical mental model: every component implements the Runnable interface (invoke, stream, batch), and legacy functionality now lives in the separate langchain-classic package.
What This Cheat Sheet Covers
This topic spans 22 focused tables and 169 indexed concepts, 145 flashcards, 7 practice tests with 207 questions. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Core Components
These are the building blocks you assemble into any LangChain app β chat models, prompts, output parsers, embeddings, vector stores, and the loaders and splitters that prep your data. The unifying idea is that nearly every one of them implements the same Runnable interface, so once you know how one works, you know how to invoke, stream, and batch them all.
| Component | Example | Description | |
|---|---|---|---|
ChatOpenAI(model="gpt-4o")ChatAnthropic(model="claude-3-5-sonnet") | β’ Unified wrappers for conversational LLMs from OpenAI, Anthropic, Google, and more β’ returns structured AIMessage objects with metadata | ||
from langchain.chat_models import init_chat_modelllm = init_chat_model("openai:gpt-4o")llm = init_chat_model("anthropic:claude-3-5-sonnet") | β’ Unified model initialization via provider:model string β no provider-specific import neededβ’ supports fully configurable runtime model selection via config["configurable"]β’ recommended v1.0 pattern for provider-agnostic code | ||
OpenAIEmbeddings()HuggingFaceEmbeddings() | β’ Convert text to vectors for semantic search β’ used with vector stores; supports batch processing for efficiency | ||
PromptTemplate(template="Answer: {question}")ChatPromptTemplate.from_messages([...]) | β’ Templating system for dynamic prompt construction β’ supports f-string syntax, Jinja2, and chat message formatting | ||
JsonOutputParser()PydanticOutputParser(pydantic_object=MyModel) | β’ Extract structured data from LLM text responses β’ handles JSON, Pydantic models, lists, and custom formats with validation | ||
chain.invoke(input)chain.stream(input)chain.batch([inputs]) | β’ Unified execution protocol for all LangChain components β’ enables invoke (single), stream (tokens), batch (multiple), and async variants | ||
message.content_blocks# β [ThinkingBlock(...), TextBlock(...), ToolUseBlock(...)] | β’ Provider-agnostic message content added in LangChain v1.0 β’ unified access to reasoning traces, citations, tool calls across providers β’ existing message.content unchanged for backward compatibility | ||
PyPDFLoader("file.pdf")CSVLoader("data.csv")WebBaseLoader("https://...") | β’ Ingest data from PDFs, CSVs, HTML, Markdown, APIs, databases β’ returns Document objects with page_content and metadata | ||
RecursiveCharacterTextSplitter(chunk_size=1000)HTMLHeaderTextSplitter() | β’ Chunk documents into smaller pieces for embedding/retrieval β’ preserves semantic structure; critical for RAG quality | ||
Chroma.from_documents(docs, embeddings)Pinecone.from_existing_index() | β’ Store and search embeddings using similarity metrics β’ integrates with 60+ vector databases; supports metadata filtering | ||
vectorstore.as_retriever(search_type="mmr")MultiQueryRetriever.from_llm() | β’ Fetch relevant documents from vector stores β’ supports similarity search, MMR, hybrid search, and contextual compression | ||
OpenAI(model="gpt-3.5-turbo-instruct") | β’ Legacy text-completion models (non-chat); takes string, returns string β’ mostly superseded by chat models; in langchain-classic in v1.0 |