LangChain
LangChain is an open-source framework for building LLM applications and agents from swappable models, tools, retrievers, and middleware.
LangChain is an open-source framework for building applications and AI agents on top of large language models (LLMs). It gives every model provider the same interface for messages, chat models, tools, and retrievers, so an application can switch from one provider's model to another's by changing a model name, and it supplies ready-made agent loops and hundreds of integrations with vector stores, document loaders, and APIs. Harrison Chase released LangChain as an open-source Python project in October 2022, weeks before ChatGPT launched, and it became one of the most widely used toolkits for chaining prompts, retrieval, and model calls into generative AI applications. LangChain 1.0 and LangGraph 1.0 shipped together on October 22, 2025, with a commitment to no breaking changes until version 2.0.
The LangChain Ecosystem#
The name now covers a family of packages, available in Python and JavaScript:
- langchain: The agent framework, centered on
create_agent, which takes a model, a list of tools, and a system prompt and returns a working agent. - langchain-core and integrations: Standard interfaces for chat models, messages, embeddings, retrievers, and tools, plus provider packages such as langchain-openai and langchain-anthropic that implement them.
- LangGraph: The lower-level runtime that LangChain agents run on. It models a program as a graph of steps over shared state and can checkpoint that state after every step, so long tasks survive restarts and can pause for human approval.
- LangSmith: A hosted platform for observability traces, agent evaluation on datasets, and agent deployment.
Classic LangChain apps were chains: a prompt template filled with the user's input, a model call, and an output parser, composed with a pipe syntax as in prompt chaining. The most common chain is retrieval-augmented generation (RAG), which loads documents, splits them into chunks, stores their embeddings in a vector database, and adds the chunks that best match each question to the model's context window.
How a LangChain Agent Runs#
An agent built with create_agent repeats a loop of model calls and tool calls, the same function calling loop every agent harness runs. Middleware hooks into each step to change what happens around the model: built-in middleware summarizes long histories, redacts personal data, and pauses for human approval before chosen tools run.
Giving a LangChain Agent Vision#
LangChain's @tool decorator turns a Python function into a tool, reading the argument types from its signature and the description from its docstring. Wrapping Ultralytics YOLO26 this way gives an agent object detection, with Results.summary() returning each detection's class name, confidence, and box as data the model can read:
from langchain_core.tools import tool
from langchain_core.utils.function_calling import convert_to_openai_tool
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
@tool
def detect_objects(image_url: str) -> list[dict]:
"""Detect objects in an image and return each one's class name, confidence, and box."""
results = model(image_url)
return results[0].summary()
# The schema LangChain derives from the signature and docstring, as a model receives it
print(convert_to_openai_tool(detect_objects))
# An agent runs the tool with the arguments from the model's tool call
detections = detect_objects.invoke({"image_url": "https://ultralytics.com/images/bus.jpg"})
print(detections[0]["name"], detections[0]["confidence"])The first print shows the function definition, with an image_url string parameter and the docstring as its description, that LangChain sends to the model; the second shows the first detection the tool returns. Passing tools=[detect_objects] to create_agent lets any supported chat model call the detector through predict mode.
LangChain vs. Related Tools#
- Agentic workflows: The general design patterns, such as routing, tool use, and evaluator loops, that LangGraph graphs and LangChain agents implement.
- Provider SDKs: Calling a model provider's API directly needs no framework and suits single-model apps. LangChain adds the shared interfaces, integrations, and agent loop that matter once an app spans several models, tools, or data sources.
- DSPy: A framework that writes and optimizes the prompts of a multistep LLM program automatically, tuning them against a metric on example data.
- LlamaIndex: A framework centered on ingesting, indexing, and querying private data for RAG. The two overlap, and applications often use LlamaIndex for retrieval inside a LangChain or LangGraph agent.










