Open-Source Wikis

/

LangChain

/

LangChain

langchain-ai/langchain

LangChain

LangChain is a Python framework for building agents and LLM-powered applications. It provides a layered set of abstractions — model interfaces, message types, tools, runnables — that let developers swap providers, compose workflows, and ship to production without rewriting glue code.

The repository at langchain-ai/langchain is a uv-managed monorepo of independently versioned Python packages. The langchain package (defined in libs/langchain_v1/) sits at the top of the stack and provides agent construction; langchain-core (libs/core/) defines the abstractions everything builds on; partner packages under libs/partners/ integrate concrete model providers (OpenAI, Anthropic, Ollama, …).

What this wiki covers

  • Architecture — how the layers fit together and where data flows
  • Getting started — installing, building, and running tests across the workspace
  • Glossary — vocabulary used in code and docs (Runnable, message, content block, middleware, …)
  • Packages — every package in libs/
  • Partners — the model-provider integrations under libs/partners/
  • Primitives — the cross-cutting abstractions in langchain-core
  • Features — agents, middleware, structured output, and the chat-model factory
  • How to contribute — workflow, testing, lint, conventions
  • By the numbers — codebase statistics
  • Lore — timeline of how the codebase evolved
  • Reference — configuration, dependencies, and pointers

Quick orientation

For end users, two entry points cover most of what LangChain does:

# 1. Initialize a chat model from any supported provider
from langchain.chat_models import init_chat_model
model = init_chat_model("openai:gpt-5")
result = model.invoke("Hello, world!")

# 2. Build an agent with tools and middleware
from langchain.agents import create_agent
agent = create_agent(model="openai:gpt-5", tools=[...], middleware=[...])
agent.invoke({"messages": [{"role": "user", "content": "..."}]})

init_chat_model is implemented in libs/langchain_v1/langchain/chat_models/base.py and dispatches to the right partner package. create_agent lives in libs/langchain_v1/langchain/agents/factory.py and builds a langgraph state graph under the hood.

Where things live

Area Path
Base abstractions (Runnable, messages, models, tools, callbacks) libs/core/langchain_core/
Modern langchain package (agents, middleware, init_chat_model) libs/langchain_v1/langchain/
Legacy langchain-classic (chains, agents, indexing, community re-exports) libs/langchain/langchain_classic/
Provider integrations libs/partners/<provider>/
Document chunking libs/text-splitters/
Standard test suite for integrations libs/standard-tests/
Model capability data and CLI libs/model-profiles/
CI workflows .github/workflows/

Outside this repo

LangChain integrations are not all in this monorepo. Some live in sibling repos that the project assumes can be cloned next to langchain/ (for example langchain-google, langchain-aws). The init_chat_model registry in libs/langchain_v1/langchain/chat_models/base.py lists them. LangChain also pairs with langgraph (low-level orchestration) and langsmith (observability), both of which langchain-core depends on directly.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

LangChain – LangChain wiki | Factory