Skip to main content

What Is LangChain?

LangChain is an open-source framework, for Python and JavaScript, for building AI agents: programs in which an AI model decides what to do next and calls your code to do it. Its central piece, create_agent, wraps a model in what LangChain calls a harness: the prompt, the tools and everything else around the loop in which the model calls those tools. This page explains both, shows a small agent running on Claude in a few lines of Python, and maps every concept of LangChain to the tutorial in this track that teaches it.

What LangChain Does​

The AI behind an agent is a large language model (LLM), such as Claude. On its own, a model only turns text into more text. It can't look anything up in your systems, and it can't do anything in them. LangChain is the code around the model that changes that. Its overview sums it up as Agent = Model + Harness. The harness is everything around the model loop: the prompt, the tools, and any middleware that shapes behavior. The agents page adds what the harness is for: get the model the right context at the right time for the given task.

LangChain's philosophy page names its two core focuses:

  1. We want to enable developers to build with the best models. Every model provider has its own API, and LangChain gives them one interface, so you can move to another model with minimal code changes.
  2. We want to make it easy to use models to orchestrate more complex flows that interact with other data and computation. That's what tools are for: LangChain makes it easy to define tools that models can use.

Where It Comes From​

LangChain started on October 24, 2022, a month before ChatGPT, as a Python package for chaining steps around a model. The name LangChain comes from "Language" (like Language models) and "Chains". A company, LangChain Inc., formed around the project in 2023. LangGraph, its lower-level runtime, followed in 2024.

LangChain 1.0, released on October 20, 2025, was a clean break. It replaced all chains and agents with only one high level abstraction: an agent abstraction built on top of LangGraph. That abstraction is create_agent, and it's what this track teaches.

  • Languages: Python and JavaScript. This track uses Python 3.14.
  • License: open source under the MIT license, and free.
  • Versions: this track uses langchain 1.5.2, released on November 18, 2026.

The LangChain Family​

LangChain is one of several products from the same company, and their names are easy to mix up. LangGraph's overview describes how they fit together. These are the four this page refers to:

ProductWhat LangChain says it isIn this track
LangChainThe agent framework: abstractions and integrations for models, tools, and agent loopsEverything: create_agent and the concepts around it
LangGraphThe orchestration runtime: durable execution, streaming, human-in-the-loop, and persistenceUnder every agent. You meet it directly in memory, streaming and human-in-the-loop
Deep AgentsAn agent harness: planning, subagents, filesystem tools, and context management on top of LangGraphNot covered here
LangSmithThe platform for tracing, evaluation, prompts, and deployment across frameworksTracing runs and debugging agents, later in the track

LangChain's agents run on LangGraph: This allows us to take advantage of LangGraph's durable execution, human-in-the-loop support, persistence, and more. LangGraph doesn't need LangChain, though. LangGraph's overview points you to LangChain's agents, or to Deep Agents, when you want a higher-level agent loop, and to LangGraph itself when you need explicit control over state and control flow.

What an Agent Is​

LangChain's agents page defines it in one sentence: An agent is a model calling tools in a loop until a given task is complete.

In Python, you make one with create_agent. You give it a model, a system prompt that tells the model who it is and how to behave, and tools: Python functions the model may ask to call. Then you call invoke with a message, and you get back every message of the run, with the model's answer last.

An Agent in a Few Lines of Python​

Here's a complete agent for a windowsill of plants. It runs on Claude Opus 5.5 and has one tool, a Python function that reads the moisture sensor in a plant's pot. To keep the example small, the function returns a fixed reading: 18% for basil and 62% for any other plant. You'll build an agent yourself, step by step, later in this track. For now, read the code and look at what it prints.

main.py
from dotenv import load_dotenv
from langchain.agents import create_agent

load_dotenv() # Reads ANTHROPIC_API_KEY from the .env file.


def get_soil_moisture(plant: str) -> str:
"""Read the moisture sensor in a plant's pot. Returns how damp the soil is, as a percentage."""
print(f"(get_soil_moisture was called with plant = {plant})")
return "18%" if plant.lower() == "basil" else "62%"


# An agent: a Claude model, instructions, and one tool it may call.
agent = create_agent(
model="anthropic:claude-opus-5-5",
tools=[get_soil_moisture],
system_prompt="You help someone look after the plants on their windowsill. Answer in one or two sentences of plain text.",
)

for question in ["Should I water my basil today?", "Where does basil come from?"]:
result = agent.invoke({"messages": [{"role": "user", "content": question}]})
print(result["messages"][-1].text)

macOS-style code window titled main.py — windowsill-agent showing a LangChain agent in Python: load_dotenv, a get_soil_moisture function that prints a line and returns 18% for basil and 62% otherwise, create_agent with the model anthropic, that tool and a windowsill system prompt, and a loop that asks two questions and prints each answer's text.

  • load_dotenv() reads your Claude API key, ANTHROPIC_API_KEY, from a .env file next to the code, so the key never appears in the code itself.
  • get_soil_moisture is an ordinary Python function. create_agent turns it into a tool. Claude never sees the function's code. It sees the tool's name, its description, which LangChain takes from the docstring, and its one argument, a string called plant.
  • create_agent builds the agent from the model, the tools and the system prompt. "anthropic:claude-opus-5-5" names a provider and a model: Anthropic's Claude Opus 5.5, reached through the langchain-anthropic package.
  • agent.invoke runs the agent on one message and returns the result of the run. Its "messages" list holds every message, so [-1] is the last one, the answer, and .text is its text.
  • The print in get_soil_moisture prints a line each time the tool runs, so you can see when Claude used it.

When I ran it with uv run main.py, it printed:

Output
(get_soil_moisture was called with plant = basil)
Yes, water it today. The soil is only 18% moist, which is too dry for basil because it likes its soil kept evenly damp.
Basil most likely comes from tropical Asia, especially India, where people have grown it for thousands of years. From there it spread through the Middle East and into the Mediterranean, where it became a key part of Italian cooking.

macOS-style terminal window titled Terminal — windowsill-agent showing uv run main.py printing (get_soil_moisture was called with plant = basil), then an answer that says to water the basil today because the soil is only 18% moist, then an answer that says basil most likely comes from tropical Asia, especially India.

Nothing in the code says when to use the tool. For the first question, Claude decided it had to check the soil, asked for get_soil_moisture with plant = basil, and wrote its answer from the 18% it got back. For the second, it didn't need the tool: where basil comes from is general knowledge, so it answered straight away, and no tool line appears.

Run the app again and the words change. In another run, the second answer began Basil (*Ocimum basilicum*) is native to tropical regions from central Africa to Southeast Asia, with the plant's Latin name between asterisks, Markdown for italics, even though the system prompt asks for plain text. A model writes every answer fresh. Instructions steer it, but they don't guarantee anything.

What Happens During a Run​

The first question took two calls to the model:

The first call sends the system prompt, the question and the tool's description, and Claude answers with a request to call get_soil_moisture. The agent runs your function and sends the result back in a second call, and only then does Claude write the answer. That's the loop in LangChain's definition, and create_agent runs it for you: you write the function, and the agent handles the back-and-forth until the model has its answer.

To check, I printed every message of the run, as How to See Every Message in a LangChain Agent Run in Python shows. There were four: the question, Claude's request to call get_soil_moisture with plant: basil, the tool's result 18%, and Claude's answer.

The Agent Is a Graph​

create_agent returns a LangGraph graph, a CompiledStateGraph: every LangChain agent is one. The graph has a node that calls the model and a node that runs the tools, and LangChain can draw it, as How to Draw a LangChain Agent as a Mermaid Diagram in Python shows. This is the windowsill agent's graph, redrawn from what draw_mermaid() printed for it:

The dotted arrows are choices the agent makes on each pass. After model, it goes to tools when Claude asked for a tool, or to __end__ when Claude answered. From tools, it goes back to model, which reads the tool's result. Most of the concepts in this track plug into this picture: middleware runs around the model and tools nodes, memory saves the graph's state between runs, and human-in-the-loop pauses it before a tool runs.

Models You Can Use​

create_agent takes the model as a "provider:model" string, or as a model object you've set up yourself. LangChain's overview says it supports OpenAI, Anthropic, Google, and more, each through its own package, such as langchain-anthropic for Claude and langchain-openai for OpenAI. Switching to another provider means changing that string and adding the provider's package.

This track uses Claude Opus 5.5 (claude-opus-5-5) for every agent. Two things about it matter from the start:

  • It always thinks before it answers. Anthropic's documentation says thinking can't be turned off on Claude Opus 5.5. By default, the thinking text isn't returned: you get an empty thinking block with an encrypted signature, which LangChain shows as a reasoning block with no text. The thinking tokens are still billed as output tokens.
  • Effort sets how hard it works. Claude Opus 5.5 supports five effort levels, from low to max, and uses medium unless you say otherwise. LangChain's Claude integration takes it as effort= on ChatAnthropic, the class behind the "anthropic:" string.

Later in the track, OpenAI's embedding models join Claude: they turn text into lists of numbers, so an agent can search your documents by meaning.

The Packages​

LangChain comes as a set of packages, and a project adds only the ones it uses. These are the ones this track uses:

PackageWhat it gives youVersion
langchaincreate_agent, middleware and the rest of the agent harness1.5.2
langchain-coreThe building blocks the other LangChain packages share, such as messages, tools and the chat model interface1.8.5
langgraphThe runtime every agent runs on1.2.25
langchain-anthropicClaude models1.7.13
langchain-openaiOpenAI models, used in this track for embeddings1.8.5
langchain-text-splittersSplitting documents into chunks for search1.2.0
langgraph-checkpoint-sqliteSaving conversations in a SQLite file3.1.3
langchain-mcp-adaptersTools from MCP servers0.3.2
langsmithSending traces to LangSmith, when you turn tracing on0.16.4

You don't add them all at once. The windowsill agent needed only two of them, plus python-dotenv for the .env file: uv add langchain langchain-anthropic python-dotenv. Those brought langchain-core, langgraph and langsmith with them. To see which versions a project has, run uv run python -m langchain_core.sys_info, and How to See Which LangChain Packages Are Installed with langchain_core.sys_info explains its report.

Why Python 3.14​

LangChain 1.5 needs Python 3.11 or later, and lists Python 3.11 to 3.14 as supported. Python 3.15 is out, but a package that every LangChain project installs isn't ready for it yet: zstandard. langchain-core depends on langsmith, which needs zstandard, and the newest zstandard, 0.25.0, has no ready-built package (a wheel) for Python 3.15, so on 3.15 it has to be compiled from source. On Python 3.14, everything installs from wheels, on macOS and Windows alike. Every project in this track starts with uv init --python 3.14.

Every Concept, and Where This Track Teaches It​

This track teaches LangChain one concept at a time, in the order below. Each tutorial has its own small example, like the windowsill agent on this page, and builds only on the tutorials before it. They're published one at a time, and each concept becomes a link here when its tutorial is out.

ConceptWhat it lets you doWhere you'll learn it
What LangChain isKnow what LangChain, LangGraph and LangSmith are, and how an agent runsThis page
Your Python environmentCreate a Python 3.14 project, install LangChain and make a first call to ClaudeComing soon
Your first agentCreate an agent with a tool, run it and read its messagesComing soon
Chat modelsCall a model directly: settings, streaming, batches, token usage and Claude's effortComing soon
Messages and content blocksRead and build messages, including reasoning, tool calls, images and PDFsComing soon
ToolsTurn Python functions into tools with clear descriptions, typed arguments and error handlingComing soon
Agents in depthUse every option of create_agent: system prompts, the loop and its limitsComing soon
Structured outputGet a typed Python object back instead of textComing soon
Short-term memoryKeep a conversation going across several messagesComing soon
StreamingShow the answer and the agent's progress while it worksComing soon
Event streamingFollow every event of a run as it happensComing soon
MiddlewareRun your own code before and after each model and tool callComing soon
Built-in middlewareSummarize long conversations, limit calls, retry and fall back to another modelComing soon
Human-in-the-loopMake a person approve, edit or reject a tool call before it runsComing soon
GuardrailsCatch personal data and unsafe content before and after the modelComing soon
Runtime and contextPass a user, a connection or settings into tools and middlewareComing soon
Context engineeringControl exactly what the model sees at each stepComing soon
Long-term memoryRemember things across conversationsComing soon
Embeddings and vector storesTurn text into vectors and search them by meaningComing soon
Loading and splitting documentsLoad files and split them into chunks for searchComing soon
Retrieval-augmented generation (RAG)Answer from your own documents, with citationsComing soon
Better retrievalImprove search results with filters, query rewriting, hybrid search and rerankingComing soon
MCP toolsUse the tools an MCP server offersComing soon
MCP connections and authenticationConnect to several MCP servers, with sign-inComing soon
SubagentsLet one agent call other agents as toolsComing soon
HandoffsHand a conversation from one agent to anotherComing soon
SkillsLoad instructions only when the agent needs themComing soon
Routers and custom workflowsSend each request to the right agent, or build your own LangGraph workflowComing soon
Tracing with LangSmithSee every step of every run in LangSmithComing soon
LangSmith Studio and the local agent serverRun an agent as a local server and debug it in StudioComing soon
Agent Chat UIChat with your agent in a web pageComing soon
Streaming into a React appShow an agent's stream in your own web interfaceComing soon
Going to productionThe ways to run an agent in production, and what each one costsComing soon

The Product Lines​

Below the Fundamentals in the sidebar, three product lines will put the concepts together in complete applications, each built from an empty folder to a finished product, one part at a time. Where a part uses a concept, it links the concept's tutorial and spends its own words on what's specific to the product. All three are coming soon:

  • Data Analyst Agent answers plain-English questions about a database with read-only SQL, asks before a query runs, and gives structured answers.
  • Research Paper Assistant finds and reads research papers, and answers with citations.
  • GitHub Issue Triage Agent triages a repository's issues through GitHub's MCP server: labels, priorities and duplicates, with your approval before every change.

What It Costs​

  • LangChain and LangGraph: nothing. Both are open source under the MIT license.
  • Claude: you pay Anthropic for the tokens your agents send and receive. Claude Opus 5.5 costs $4 per million input tokens and $20 per million output tokens. There's no free tier: Anthropic's pricing page says the Claude API has no free tier or self-serve trial, and new accounts don't include free credits, and the smallest credit purchase is $5. How to Get a Claude API Key shows how to buy credit and create a key.
  • LangSmith: optional. Nothing is sent to it unless you turn tracing on, and the tutorial that uses it covers its plans before you sign up.

To see what that means in practice, I measured the windowsill agent's two questions. The first used 935 input and 134 output tokens over its two calls to Claude. The second used 436 and 112. That's 1,371 input and 246 output tokens, or about $0.0104 for both questions, so you could run the app about 96 times for a dollar. Most of the input is the same every time: the system prompt, the tool's description and the 286 tokens of instructions that Anthropic adds to every request with tools. How to Get the Token Usage and Cost of a LangChain Agent Run in Python measures a run the same way.

Tools You'll Use​

ToolWhat it's for
uvCreates Python 3.14 projects, installs packages and runs your code
A code editor, such as Visual Studio CodeWriting the code
A Claude API key with creditThe model your agents use

The next tutorial, Set Up Your Python Environment, checks uv, creates a project with LangChain and makes a first call to Claude.

Frequently Asked Questions​

Is LangChain free?​

Yes. LangChain and LangGraph are open source under the MIT license, and their packages are free. You pay for the services your agents use, such as the AI model.

What's the difference between LangChain and LangGraph?​

LangChain is the agent framework: create_agent, the model integrations and tools. LangGraph is the runtime underneath: the graph that runs the agent loop, and the persistence, streaming and human-in-the-loop that come with it. Every LangChain agent is a LangGraph graph, but you can use LangGraph without LangChain, when you want to draw every step and path of an application yourself.

Do I need LangSmith?​

No. The windowsill agent ran with no LangSmith account, and LangChain sends nothing to LangSmith unless you set LANGSMITH_TRACING=true and a LangSmith API key. LangSmith helps you see what an agent did, and this track uses it later for exactly that.

Can I use OpenAI or another model instead of Claude?​

Yes. Change the "provider:model" string and add the provider's package, such as langchain-openai. Different models behave differently, though, so this track uses Claude throughout, and every output on these pages comes from Claude Opus 5.5.

What happened to LangChain's chains?​

LangChain 1.0 replaced all chains and agents with the one agent abstraction this track teaches. The old chains and agents live on in the langchain-classic package, for apps that don't want to move yet. LangChain recommends moving.

Can I use JavaScript instead of Python?​

Yes. LangChain has had a JavaScript version since January 2023, with its own documentation. This track uses Python throughout, so every example, command and output here is Python.

Conclusion​

LangChain is the code between an AI model and a useful application. create_agent gives a model a system prompt and tools, and runs the loop in which the model calls the tools until it has its answer. The agent is a LangGraph graph underneath, which is where memory, streaming and human approvals come from, and LangSmith shows you what each run did. The windowsill agent showed the loop in about twenty lines of Python, for about a cent.

Next: Set Up Your Python Environment (coming soon) checks uv, creates a Python 3.14 project with LangChain, keeps your Claude API key in a .env file and makes a first call to Claude.

Additional Resources​

  • LangChain overview — Agent = Model + Harness, and when to use LangChain, LangGraph or Deep Agents.
  • Agents — create_agent and the agent loop.
  • Philosophy — why LangChain exists, and its history from 2022 to today.
  • LangGraph overview — the runtime under every LangChain agent, and how the products fit together.
  • ChatAnthropic — Claude in LangChain, including effort.
  • Claude pricing — what each Claude model costs per token.
  • langchain on PyPI — releases and supported Python versions.