docs
Complete API reference for all LangChain components. Each section provides detailed type definitions, parameter descriptions, and usage examples.
Want task-based examples instead? See the Task Index for "I want to..." → code mappings.
Complete API for creating and executing ReAct agents.
Key APIs:
createAgent() - Create production-ready agentsReactAgent class - Agent execution methods (invoke, stream, batch)API for creating tools that agents can use.
Key APIs:
tool() - Create structured toolsDynamicTool - String-input toolsStructuredTool - Schema-based toolsDynamicStructuredTool - Dynamic structured toolsUniversal model initialization API.
Key APIs:
initChatModel() - Initialize chat models from any providerMessage types and utilities for agent communication.
Key APIs:
HumanMessage - User messagesAIMessage - Assistant messagesSystemMessage - System instructionsToolMessage - Tool resultsfilterMessages() - Filter message arraystrimMessages() - Trim messages to fit contextType-safe structured response generation.
Key APIs:
toolStrategy() - Tool-based structured outputproviderStrategy() - Provider-native structured outputToolStrategy classProviderStrategy classView Structured Outputs API Reference →
Storage implementations for persisting data.
Key APIs:
InMemoryStore - In-memory key-value storeExecution context utilities.
Key APIs:
context.get() - Get context valuescontext.set() - Set context valuescontext.run() - Run with contextcontext.runAsync() - Async context executionDocument representation for text processing.
Key APIs:
Document class - Document containerView Documents API Reference →
// Import commonly used APIs
import {
createAgent,
tool,
initChatModel,
HumanMessage,
AIMessage,
SystemMessage,
toolStrategy,
providerStrategy,
createMiddleware,
InMemoryStore,
} from "langchain";function createAgent<TConfig>(params: CreateAgentParams): ReactAgent<TConfig>;function tool<T = any>(
func: (input: T, config?: ToolConfig) => any | Promise<any>,
fields: {
name: string;
description: string;
schema: ZodType<T>;
}
): StructuredTool<T>;function initChatModel<RunInput = any, CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions>(
model?: string | ChatModel,
fields?: InitChatModelFields
): ChatModel<RunInput, CallOptions>;// Infer types from agents
type InferAgentState<T>
type InferAgentResponse<T>
type InferAgentContext<T>
type InferAgentTools<T>
type InferAgentMiddleware<T>
// Infer types from middleware
type InferMiddlewareState<T>
type InferMiddlewareStates<T extends readonly AgentMiddleware[]>
type InferMiddlewareContext<T>
type InferMiddlewareContexts<T extends readonly AgentMiddleware[]>
type InferMiddlewareTools<T extends readonly AgentMiddleware[]>
// Schema inference
type InferSchemaInput<A>
type InferContextInput<ContextSchema>Quick lookup for all error classes:
MultipleToolsBoundError - Tools already bound to modelMultipleStructuredOutputsError - Multiple outputs returnedStructuredOutputParsingError - Failed to parse outputToolInvocationError - Tool execution failedToolCallLimitExceededError - Tool call limit exceededPIIDetectionError - PII detection failedComplete error handling guide →
// Agent types
type CreateAgentParams
type ReactAgent<TConfig>
type UserInput<TStateSchema>
type State<TConfig>
type InvokeConfiguration<ContextSchema>
type StreamConfiguration<ContextSchema>
type BatchConfiguration<ContextSchema>
// Tool types
type Tool
type ToolCall
type ToolResult
type ToolConfig
type ToolRuntime
// Message types
type BaseMessage
type MessageInput
type ContentBlock
// Middleware types
type AgentMiddleware<TSchema, TContextSchema, TFullContext, TTools>
type MiddlewareConfig<TSchema, TContextSchema, TTools>
// Response format types
type ResponseFormat
type JsonSchemaFormat
// Runtime types
type Runtime<TContext>Getting Started
API References
Advanced Topics
Middleware
Integrations
Building Agents
Adding Tools
Structured Outputs
Using Middleware
Type Safety