Learn LangChain

Build LLM apps and agents: models, prompts, tools, retrieval and LangGraph

18 lessons · 4 hours · 4 levels · covers LangChain 1.x (langchain-core 1.x, LangGraph 1.x)

LangChain is a Python framework for building applications on large language models. It gives a common interface to chat models from many providers, prompt templates, composable runnables (LCEL), tools and structured output, retrieval components for RAG, and agents built on LangGraph, its low-level library for stateful, durable agent workflows. It is one of the most widely used toolkits for LLM apps.

Before you start

LangChain builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics5 lessons · 52 min in total
2. PracticalUse it productively at work, with the usual idioms11 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs15 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know18 lessons · 4 hours in total

The LangChain tree

LangChainThe LangChain ecosystemThe LangChainecosystemChat modelsChat modelsMessages and conversation historyMessages andconversation historyPrompt templatesPrompt templatesChains with LCELChains with LCELStructured outputStructured outputTools and tool callingTools and tool callingRunnable compositionRunnablecompositionStreaming and asyncStreaming and asyncAgents with create_agentAgents withcreate_agentDocuments, loaders and splittersDocuments, loadersand splittersDefining functionsDefining functionsStrings and f-stringsStrings and f-stringsType hints basicsType hints basicsFunctions as objects, lambdas and closuresFunctions as objects,lambdas and closur…Iterators and generatorsIterators andgeneratorsTesting with pytest and unittestTesting with pytestand unittest
Essentials and Practical shown (11 of 18 lessons); the full list is below. Click a lesson to read it.

All 18 lessons, in order

Models and messages

  1. The LangChain ecosystem · Essentials · 8 min

    Know the packages (langchain, langchain-core, provider packages, LangGraph, LangSmith) and how they fit together.

  2. Chat models · Essentials · 12 min

    Create a chat model with init_chat_model or a provider class and call it with invoke, batch and stream.

  3. Messages and conversation history · Essentials · 10 min

    Work with system, human, AI and tool messages, and pass conversation history to the model.

Prompts and LCEL

  1. Prompt templates · Essentials · 10 min

    Build reusable prompts with ChatPromptTemplate, variables and MessagesPlaceholder.

  2. Chains with LCEL · Essentials · 12 min

    Compose prompt, model and output parser with the | operator into a runnable chain.

  3. Runnable composition · Practical · 14 min

    Use RunnableParallel, RunnablePassthrough, RunnableLambda, config, retries and fallbacks to build richer chains.

  4. Streaming and async · Practical · 12 min

    Stream tokens and intermediate events to users, and run chains concurrently with async methods.

Tools, structured output and agents

  1. Structured output · Practical · 12 min

    Get validated Pydantic objects or typed dicts from a model with with_structured_output.

  2. Tools and tool calling · Practical · 14 min

    Define tools with @tool, bind them to a model, and execute the tool calls the model requests.

  3. Agents with create_agent · Practical · 14 min

    Build a tool-using agent with create_agent, run it on messages, and understand its model-tool loop.

Retrieval and RAG

  1. Documents, loaders and splitters · Practical · 12 min

    Load source data into Document objects and split it into chunks sized for embedding and retrieval.

  2. Embeddings, vector stores and retrievers · Advanced · 14 min

    Embed chunks, store them in a vector store, and query them by similarity through the retriever interface.

  3. Retrieval-augmented generation · Advanced · 15 min

    Answer questions from your own documents with a retrieval chain or a retrieval tool for an agent.

LangGraph

  1. LangGraph: state, nodes and edges · Advanced · 15 min

    Build explicit workflows as graphs with typed state, node functions, normal and conditional edges.

  2. Memory and persistence · Advanced · 14 min

    Give agents and graphs conversation memory with checkpointers and thread IDs, and long-term memory with stores.

Production agents

  1. Agent middleware · Expert · 14 min

    Customize create_agent with middleware hooks for dynamic prompts, summarization, limits, retries and guardrails.

  2. Interrupts and human-in-the-loop · Expert · 14 min

    Pause a graph or agent for human approval with interrupt and resume it with Command, using persisted state.

  3. Testing, tracing and evaluation · Expert · 14 min

    Unit-test chains and agents with fake models, trace runs with LangSmith or callbacks, and evaluate quality.