CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-langchain

TypeScript framework for building LLM-powered applications with agents, tools, middleware, and model interoperability

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/api-reference/

API Reference Index

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.

Core APIs

Agents

Complete API for creating and executing ReAct agents.

Key APIs:

  • createAgent() - Create production-ready agents
  • ReactAgent class - Agent execution methods (invoke, stream, batch)
  • Agent configuration types
  • State and runtime types
  • Type inference utilities
  • Error classes

View Agent API Reference →

Tools

API for creating tools that agents can use.

Key APIs:

  • tool() - Create structured tools
  • DynamicTool - String-input tools
  • StructuredTool - Schema-based tools
  • DynamicStructuredTool - Dynamic structured tools
  • Tool configuration types

View Tools API Reference →

Models

Universal model initialization API.

Key APIs:

  • initChatModel() - Initialize chat models from any provider
  • Model configuration types
  • Supported providers

View Models API Reference →

Messages

Message types and utilities for agent communication.

Key APIs:

  • HumanMessage - User messages
  • AIMessage - Assistant messages
  • SystemMessage - System instructions
  • ToolMessage - Tool results
  • filterMessages() - Filter message arrays
  • trimMessages() - Trim messages to fit context

View Messages API Reference →

Structured Outputs

Type-safe structured response generation.

Key APIs:

  • toolStrategy() - Tool-based structured output
  • providerStrategy() - Provider-native structured output
  • ToolStrategy class
  • ProviderStrategy class
  • Response format types
  • Error classes

View Structured Outputs API Reference →

Storage

Storage implementations for persisting data.

Key APIs:

  • InMemoryStore - In-memory key-value store
  • Storage interface types

View Storage API Reference →

Context

Execution context utilities.

Key APIs:

  • context.get() - Get context values
  • context.set() - Set context values
  • context.run() - Run with context
  • context.runAsync() - Async context execution

View Context API Reference →

Documents

Document representation for text processing.

Key APIs:

  • Document class - Document container
  • Document types

View Documents API Reference →

Quick Lookups

Most Common APIs

// Import commonly used APIs
import {
  createAgent,
  tool,
  initChatModel,
  HumanMessage,
  AIMessage,
  SystemMessage,
  toolStrategy,
  providerStrategy,
  createMiddleware,
  InMemoryStore,
} from "langchain";

Agent Creation

function createAgent<TConfig>(params: CreateAgentParams): ReactAgent<TConfig>;

Full documentation →

Tool Creation

function tool<T = any>(
  func: (input: T, config?: ToolConfig) => any | Promise<any>,
  fields: {
    name: string;
    description: string;
    schema: ZodType<T>;
  }
): StructuredTool<T>;

Full documentation →

Model Initialization

function initChatModel<RunInput = any, CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions>(
  model?: string | ChatModel,
  fields?: InitChatModelFields
): ChatModel<RunInput, CallOptions>;

Full documentation →

Type Inference

// 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>

Full documentation →

Error Reference

Quick lookup for all error classes:

Agent Errors

  • MultipleToolsBoundError - Tools already bound to model
  • MultipleStructuredOutputsError - Multiple outputs returned
  • StructuredOutputParsingError - Failed to parse output
  • ToolInvocationError - Tool execution failed

Middleware Errors

  • ToolCallLimitExceededError - Tool call limit exceeded
  • PIIDetectionError - PII detection failed

Complete error handling guide →

Type System

Core Types

// 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>

Navigation

By Category

Getting Started

API References

Advanced Topics

Middleware

Integrations

By Use Case

Building Agents

  1. Start: Agent Guide
  2. Reference: Agent API
  3. Examples: Quick Reference

Adding Tools

  1. Start: Tool Guide
  2. Reference: Tool API
  3. Patterns: Tool Guide - Patterns

Structured Outputs

  1. Start: Structured Output Guide
  2. Reference: Structured Output API
  3. Examples: Quick Reference

Using Middleware

  1. Start: Middleware Guide
  2. Reference: Middleware Overview
  3. Catalog: Built-in Middleware

Type Safety

  1. Start: Type Inference
  2. Reference: Agent Types
  3. Examples: Type Inference - Usage

Search Tips

Finding APIs

  1. By name: Use browser search (Ctrl/Cmd+F) on this index page
  2. By category: Navigate to specific API reference pages
  3. By use case: Follow the "By Use Case" navigation above
  4. Quick lookup: Check Quick Reference first

Finding Examples

  1. Quick patterns: Quick Reference
  2. Task-oriented: Guides in guides/
  3. Comprehensive: Full examples in API references
  4. Advanced: Type Inference examples

Finding Types

  1. Inference utilities: Type Inference
  2. Agent types: Agent API - Types
  3. Tool types: Tool API - Types
  4. Middleware types: Middleware Overview - Types

docs

glossary.md

index.md

quick-reference.md

task-index.md

tile.json