docs
Comprehensive index of LangChain concepts, APIs, and types for quick lookups.
Need task-based examples? See the Task Index for direct "I want to..." → code mappings.
A ReAct (Reasoning + Acting) agent that combines language models with tools to iteratively work towards solutions. Created with createAgent().
See: Agent Guide | Agent API
A function that agents can call to take actions. Created with tool() or by extending StructuredTool.
See: Tool Guide | Tool API
Composable components that extend agent behavior with cross-cutting concerns like logging, retries, or human-in-the-loop.
See: Middleware Guide | Middleware Overview
Type-safe, validated responses from agents using Zod schemas or JSON schemas.
See: Structured Output Guide | API Reference
Agent state that persists across invocations when using a checkpointer. Defined with stateSchema.
See: Agent Guide - Custom State
Read-only data provided per invocation that is not persisted. Defined with contextSchema.
Storage mechanism for persisting agent state across invocations. Enables conversation memory.
See: Agent Guide - Persistence
Creates a production-ready ReAct agent with configuration for models, tools, prompts, state, and middleware.
Signature: function createAgent<TConfig>(params: CreateAgentParams): ReactAgent<TConfig>
See: Agent API | Quick Reference
Creates a structured tool from a function and Zod schema.
Signature: function tool<T>(func: (input: T) => any, fields: { name, description, schema }): StructuredTool<T>
See: Tool API | Quick Reference
Initializes a chat model from any of 18+ supported providers using a universal interface.
Signature: function initChatModel(model?: string | ChatModel, fields?: InitChatModelFields): ChatModel
See: Model API | Quick Reference
Creates custom middleware with lifecycle hooks and state/context schemas.
Signature: function createMiddleware<TSchema, TContextSchema, TTools>(config: MiddlewareConfig): AgentMiddleware
See: Middleware Overview | Custom Middleware Guide
Creates a tool-based structured output strategy.
Signature: function toolStrategy<T>(schema: ZodType<T>, options?: ToolStrategyOptions): ToolStrategy<T>
Creates a provider-native structured output strategy.
Signature: function providerStrategy<T>(schema: ZodType<T>): ProviderStrategy<T>
Filters message arrays based on types or custom criteria.
See: Message API
Trims message arrays to fit within token limits.
See: Message API
Agent instance returned by createAgent() with methods for execution.
Methods:
invoke() - Synchronous executionstream() - Streaming executionstreamEvents() - Event streamingbatch() - Batch processingSee: Agent API - ReactAgent Class
Base class for creating tools with string input.
See: Tool API - Base Tool Class
Dynamically created tool with string input.
See: Tool API - DynamicTool Class
Tool with structured input schema (Zod).
See: Tool API - StructuredTool Class
Dynamically created structured tool.
See: Tool API - DynamicStructuredTool Class
Message class for user/human messages.
See: Message API
Message class for AI assistant responses.
See: Message API
Message class for system instructions.
See: Message API
Message class for tool execution results.
See: Message API
In-memory key-value store for agent data.
See: Storage API
Strategy class for tool-based structured outputs.
Strategy class for provider-native structured outputs.
Document container for text processing.
See: Document API
Configuration object for createAgent().
See: Agent API | Quick Reference
Input type for agent invocation with messages and state.
Agent state returned from invoke/stream with messages and custom state.
Configuration for agent invocation including context and thread_id.
See: Agent API - Configuration Types
Configuration for streaming with streamMode option.
See: Agent API - Configuration Types
Information about a tool call made by the model.
See: Agent API - Tool Types | Tool API
Result from tool execution.
Configuration passed to tools during execution.
See: Tool API
Union type for structured output formats (Zod, JSON schema, strategies).
See: Structured Output API - Response Format Types
Middleware interface with hooks and schemas.
See: Middleware Overview - Base Interface
Configuration for creating custom middleware.
See: Middleware Overview - Creating Custom Middleware
Runtime context available to middleware hooks.
See: Agent API - Runtime Types | Middleware Overview
Extracts full merged state type from agent (includes built-in state).
See: Type Inference - Agent Type Inference | Agent API
Extracts structured response type from agent.
See: Type Inference - Agent Type Inference
Extracts full merged context type from agent.
See: Type Inference - Agent Type Inference
Extracts tools array type from agent.
See: Type Inference - Agent Type Inference
Extracts middleware array type from agent.
See: Type Inference - Agent Type Inference
Extracts state type from single middleware.
See: Type Inference - Middleware Type Inference
Merges states from middleware array.
See: Type Inference - Middleware Type Inference
Extracts context type from single middleware.
See: Type Inference - Middleware Type Inference
Merges contexts from middleware array.
See: Type Inference - Middleware Type Inference
Extracts tools from middleware array.
See: Type Inference - Tool Type Inference
Infers input type from Zod schema or object.
See: Type Inference - Schema Type Inference
Converts tools array to mapped type by name.
See: Type Inference - Tool Type Inference
Thrown when attempting to bind tools/structured output to a model that already has tools bound.
See: Agent API - Error Classes | Error Handling Guide
Thrown when multiple structured outputs are returned but only one was expected.
See: Agent API - Error Classes
Thrown when structured output parsing fails.
See: Agent API - Error Classes | Structured Output API
Thrown when tool execution fails.
See: Agent API - Error Classes
Thrown when tool call limit is exceeded.
See: Built-in Middleware - Tool Call Limit
Thrown when PII detection fails.
See: Built-in Middleware - PII Detection
Pauses agent execution for human review and approval.
See: Human-in-the-Loop Guide | Built-in Catalog
Automatically summarizes and compresses message history.
See: Built-in Catalog
Detects and handles personally identifiable information.
See: Built-in Catalog
Simple PII redaction without detection configuration.
See: Built-in Catalog
Dynamically updates system prompts based on state/context.
See: Built-in Catalog
Uses an LLM to intelligently select tools based on queries.
See: Built-in Catalog
Edits or clears context and messages during execution.
See: Built-in Catalog
Limits the number of tool calls per invocation.
See: Built-in Catalog
Limits the number of model invocations.
See: Built-in Catalog
Adds todo list management capabilities to agents.
See: Built-in Catalog
Retries failed model calls with configurable backoff.
See: Built-in Catalog
Automatically falls back to alternative models on failure.
See: Built-in Catalog
Retries failed tool calls with configurable backoff.
See: Built-in Catalog
Emulates tool execution for testing without calling real tools.
See: Built-in Catalog
Uses OpenAI's moderation API to check for policy violations.
See: Built-in Catalog
Enables Anthropic's prompt caching for improved performance.
See: Built-in Catalog
Quick lookup for supported model provider formats:
openai:gpt-4o, openai:gpt-4o-minianthropic:claude-3-5-sonnet-20241022google:gemini-1.5-proollama:llama3.1cohere:command-r-plusgroq:mixtral-8x7b-32768together:meta-llama/Llama-3-70b-chat-hfSee: Model Guide | Quick Reference - Model Providers
Creating an agent with tool-calling capabilities.
See: Quick Reference - Agent with Tools | Agent Guide
Getting type-safe structured responses from agents.
See: Quick Reference - Agent with Structured Output | Structured Output Guide
Adding custom state that persists across invocations.
See: Quick Reference - Agent with Custom State | Agent Guide
Using checkpointers for conversation memory.
See: Quick Reference - Agent with Persistence | Agent Guide
Streaming agent responses in real-time.
See: Quick Reference - Streaming Responses | Agent Guide
Processing multiple inputs in parallel.
See: Agent Guide - Batch Processing
Adding human review and approval to agent workflows.
See: Human-in-the-Loop Guide | Agent Guide
OPENAI_API_KEY - OpenAI API keyANTHROPIC_API_KEY - Anthropic API keyGOOGLE_APPLICATION_CREDENTIALS - Google credentials pathCOHERE_API_KEY - Cohere API keyGROQ_API_KEY - Groq API keyMISTRAL_API_KEY - Mistral AI API keyTOGETHER_API_KEY - Together AI API keyFIREWORKS_API_KEY - Fireworks AI API keySee: Quick Reference - Environment Variables