LangChain, Inc.

LangChain

Compose LLM apps from modular building blocks.

LangChain is a framework for developing applications powered by large language models. It standardizes interfaces for models, prompts, retrievers, tools, and memory, then composes them with LCEL — the LangChain Expression Language — into runnable pipelines.

Install

bash
pip install langchain langchain-openai
bash
npm install langchain @langchain/openai

Quickstart

A minimal example to verify your setup.

python
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a concise technical writer."),
    ("user", "Explain {topic} in one paragraph."),
])

chain = prompt | ChatOpenAI(model="gpt-4o-mini") | StrOutputParser()

print(chain.invoke({"topic": "vector databases"}))

Core concepts

Runnables & LCEL

Every primitive implements the Runnable interface. The pipe operator composes them into chains that support sync, async, batch and streaming out of the box.

Models & Prompts

Unified chat-model and embeddings interfaces across 50+ providers. Prompt templates handle variables, few-shot examples, and message history.

Retrievers

Pluggable retrieval over vector stores, search APIs, and hybrid backends. Pair with document loaders and text splitters to build RAG pipelines.

Tools & Agents

Wrap any function as a tool the model can call. Agent loops are now expressed in LangGraph for explicit control flow.

Common use cases

  • Retrieval-augmented generation (RAG)
  • Chatbots and conversational interfaces
  • Structured data extraction
  • Document summarization pipelines

Resources