API Reference
The core classes and functions developers import most, mapped to their packages.
Path: api-reference
Third-party documentation. This is independently authored analysis of the public LangChain codebase — not the official docs, and not reviewed or endorsed by the LangChain team.
API Reference
LangChain's API is intentionally small at the seams: most of the symbols below are all you'll import from langchain-core, and the rest come from integration packages that implement the same interface.
Core runnables (langchain_core.runnables)
Runnable— the base interface (invoke/ainvoke/batch/abatch/stream/astream).RunnableSequence— produced bya | b.RunnableLambda— wrap a plain function.RunnablePassthrough— pass input through unchanged (attach context).RunnableParallel/RunnableMap— fan-out over the same input.RunnableBranch— conditional routing.
Messages and models
BaseMessage,HumanMessage,SystemMessage,AIMessage,ToolMessage.BaseChatModel— the interface;bind_tools(),invoke(messages),stream().ChatOpenAI(fromlangchain-openai),ChatAnthropic(fromlangchain-anthropic) — concrete chat models.
Prompts
ChatPromptTemplate.from_messages(...)— the main prompt builder.PromptTemplate.from_template("...")— simple string templates.MessagesPlaceholder("history")— inject a dynamic message list (memory, scratchpad).
Output parsers
StrOutputParser— raw string.JsonOutputParser/PydanticOutputParser— structured output.
Retrieval
BaseRetriever— the query→documents interface.RecursiveCharacterTextSplitter(fromlangchain-text-splitters) — chunking.OpenAIEmbeddings(fromlangchain-openai) — embeddings.FAISS,InMemoryVectorStore,pgvector, etc. — vector stores with.as_retriever().
Tools and agents
@tool— decorator turning a typed function into aBaseTool.create_tool_calling_agent(model, tools, prompt)— the modern agent.AgentExecutor(agent=..., tools=...)— Runnable-style agent loop withmax_iterations.StateGraph(fromlanggraph) — graph-based agents withcompile()and persistence.
Chain helpers (langchain.chains)
create_retrieval_chain(retriever, combine_docs_chain)— the RAG wrapper.create_stuff_documents_chain(llm, prompt)— "stuff all docs into the prompt" step.
Edge cases
- Import paths changed across LangChain versions (e.g. things moving from
langchaintolangchain-communityto their own package) — pin versions and verify imports at startup, not at first use. bind_toolsoutput is provider-specific JSON; always parse tool calls with the model class's own.tool_callsaccessor, not by eyeballing the raw message.- Streaming a full chain streams each Runnable's output — the intermediate prompt/retrieval steps are not tokens, so UI code should subscribe to the final model step (or LangGraph's intermediate streaming) for clean UX.
Interface
Interface
text
# langchain-core (primitives, no integrations)Runnable, RunnableSequence, RunnableLambda, RunnablePassthrough,RunnableBranch, RunnableParallel, RunnableMapBaseMessage / HumanMessage / AIMessage / SystemMessage / ToolMessageBaseChatModel · BaseLLM · BasePromptTemplate / ChatPromptTemplate / PromptTemplateBaseOutputParser / StrOutputParser / JsonOutputParser / PydanticOutputParserBaseRetriever · BaseTool / @tool · Documentcreate_retrieval_chain, create_stuff_documents_chain (langchain)# langchain (integration-agnostic orchestration)AgentExecutor, create_tool_calling_agent, create_react_agentInMemoryVectorStore (langchain_core.vectorstores)# integrations (each its own package)langchain-openai ChatOpenAI, OpenAIEmbeddingslangchain-anthropic ChatAnthropiclangchain-community FAISS, TextLoader, WebBaseLoader, ...langchain-text-splitters RecursiveCharacterTextSplitterlanggraph StateGraph, compile, MessageState, START/ENDlangchain-core.callbacks CallbackHandler, RunnableConfig
STATUSinterface
