LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraph-sdk

@langchain/langgraph-sdk

Description

LangGraph JS/TS SDK

This repository contains the JS/TS SDK for interacting with the LangGraph REST API.

Quick Start

To get started with the JS/TS SDK, install the package

pnpm add @langchain/langgraph-sdk

You will need a running LangGraph API server. If you're running a server locally using langgraph-cli, SDK will automatically point at http://localhost:8123, otherwise you would need to specify the server URL when creating a client.

import { Client } from "@langchain/langgraph-sdk";

const client = new Client();

// List all assistants
const assistants = await client.assistants.search({
  metadata: null,
  offset: 0,
  limit: 10,
});

// We auto-create an assistant for each graph you register in config.
const agent = assistants[0];

// Start a new thread
const thread = await client.threads.create();

// Start a streaming run
const messages = [{ role: "human", content: "what's the weather in la" }];

const streamResponse = client.runs.stream(
  thread["thread_id"],
  agent["assistant_id"],
  {
    input: { messages },
  }
);

for await (const chunk of streamResponse) {
  console.log(chunk);
}

Documentation

To generate documentation, run the following commands:

  1. Generate docs.

     pnpm typedoc
    
  2. Consolidate doc files into one markdown file.

     npx concat-md --decrease-title-levels --ignore=js_ts_sdk_ref.md --start-title-level-at 2 docs > docs/js_ts_sdk_ref.md
    
  3. Copy js_ts_sdk_ref.md to MkDocs directory.

     cp docs/js_ts_sdk_ref.md ../../docs/docs/cloud/reference/sdk/js_ts_sdk_ref.md
    

Reference Documentation

The reference documentation is available here.

More usage examples can be found here.

Change Log

The change log for new versions can be found here.

Classes

Class

Auth

Class

HTTPException

Class

AssistantsClient

Class

Client

Class

CronsClient

Class

RunsClient

Class

StoreClient

Class

ThreadsClient

Class

StreamError

Class

Client

Class

FetchStreamTransport

Transport used to stream the thread.

Class

SubagentManager

Manages subagent execution state.

Functions

Function

isStudioUser

Check if the provided user was provided by LangGraph Studio.

Function

getApiKey

Get the API key from the environment.

Function

overrideFetchImplementation

Overrides the fetch implementation used for LangSmith calls.

Function

getApiKey

Get the API key from the environment.

Function

getLogger

Retrieves the global logger instance for LangGraph Platform.

Function

calculateDepthFromNamespace

Calculates the depth of a subagent based on its namespace.

Function

extractParentIdFromNamespace

Extracts the parent tool call ID from a namespace.

Function

extractToolCallIdFromNamespace

Extracts the tool call ID from a namespace path.

Function

isSubagentNamespace

Checks if a namespace indicates a subagent/subgraph message.

Function

useStream

A React hook that provides seamless integration with LangGraph streaming capabilities.

Function

experimental_loadShare

Function

isRemoveUIMessage

Function

isUIMessage

Function

LoadExternalComponent

Function

uiMessageReducer

Function

useStreamContext

Function

typedUi

Helper to send and persist UI messages. Accepts a map of component names to React components

Function

uiMessageReducer

Exports

Interfaces

Types

Module

auth

Module

client

Module

index

Module

logging

Module

react

Module

react-ui

Module

react-ui/server

Interface

AuthEventValueMap

Interface

ClientConfig

Interface

Assistant

Interface

AssistantBase

Interface

AssistantGraph

Interface

AssistantsSearchResponse

Interface

AssistantVersion

Interface

BaseStream

Base stream interface shared by all stream types.

Interface

Command

Interface

Cron

Interface

CronCreateForThreadResponse

Interface

CronCreateResponse

Interface

GraphSchema

Interface

Interrupt

An interrupt thrown inside a thread.

Interface

Item

Interface

ListNamespaceResponse

Interface

Run

Interface

RunsInvokePayload

Interface

SearchItem

Interface

SearchItemsResponse

Interface

Thread

Interface

ThreadState

Interface

ThreadTask

Interface

UseAgentStream

Stream interface for ReactAgent instances created with createAgent.

Interface

UseAgentStreamOptions

Options for configuring an agent stream.

Interface

UseDeepAgentStream

Stream interface for DeepAgent instances created with createDeepAgent.

Interface

UseDeepAgentStreamOptions

Options for configuring a deep agent stream.

Interface

ClientConfig

Interface

AgentTypeConfigLike

Minimal interface matching the structure of AgentTypeConfig from @langchain/langgraph.

Interface

CompiledSubAgentLike

Minimal interface matching the structure of a CompiledSubAgent from deepagents.

Interface

DeepAgentTypeConfigLike

Minimal interface matching the structure of DeepAgentTypeConfig from deepagents.

Interface

SubAgentLike

Minimal interface matching the structure of a SubAgent from deepagents.

Interface

SubagentStreamInterface

Base interface for a single subagent stream.

Interface

SubagentToolCall

Represents a tool call that initiated a subagent.

Interface

UseStream

Interface

UseStreamOptions

Interface

UseStreamThread

Interface

UseStreamTransport

Transport used to stream the thread.

Interface

BaseStream

Base stream interface shared by all stream types.

Interface

UseAgentStream

Stream interface for ReactAgent instances created with createAgent.

Interface

UseAgentStreamOptions

Options for configuring an agent stream.

Interface

UseDeepAgentStream

Stream interface for DeepAgent instances created with createDeepAgent.

Interface

UseDeepAgentStreamOptions

Options for configuring a deep agent stream.

Interface

RemoveUIMessage

Interface

UIMessage

Interface

RemoveUIMessage

Interface

UIMessage

Type

AuthFilters

Type

RequestHook

Type

AIMessage

AI message type that can be parameterized with custom tool call types.

Type

BagTemplate

Template for the bag type.

Type

Checkpoint

Type

Config

Type

CustomStreamEvent

Streaming custom data from inside the nodes.

Type

DebugStreamEvent

Stream event with detailed debug information.

Type

DefaultValues

Type

ErrorStreamEvent

Stream event with error information.

Type

EventsStreamEvent

Stream event with events occurring during execution.

Type

FeedbackStreamEvent

Stream event with a feedback key to signed URL map. Set feedbackKeys in

Type

FunctionMessage

Type

HumanMessage

Type

InferBag

Infer the Bag type from an agent, defaulting to the provided Bag.

Type

InferNodeNames

Infer the node names from a compiled graph.

Type

InferNodeReturnTypes

Infer the per-node return types from a compiled graph.

Type

InferStateType

Infer the state type from an agent, graph, or direct state type.

Type

InferSubagentStates

Infer subagent state map from a DeepAgent.

Type

InferToolCalls

Infer tool call types from an agent.

Type

Message

Union of all message types.

Type

MessagesTupleStreamEvent

Stream event with message chunks coming from LLM invocations inside nodes.

Type

Metadata

Type

MetadataStreamEvent

Metadata stream event with information about the run and thread

Type

OnConflictBehavior

Type

RemoveMessage

Type

ResolveStreamInterface

Resolves the appropriate stream interface based on the agent/graph type.

Type

ResolveStreamOptions

Resolves the appropriate options interface based on the agent/graph type.

Type

StreamMode

import type { SubgraphCheckpointsStreamEvent } from "./types.stream.subgraph.js";

Type

SystemMessage

Type

ThreadStatus

Type

ToolMessage

Type

UpdatesStreamEvent

Stream event with updates to the state after each step.

Type

ValuesStreamEvent

Stream event with values after completion of each step.

Type

RequestHook

Type

BaseSubagentState

Base state type for subagents.

Type

DefaultSubagentStates

Default subagent state map used when no specific subagent types are provided.

Type

DefaultToolCall

Default tool call type when no specific tool definitions are provided.

Type

ExtractAgentConfig

Extract the AgentTypeConfig from an agent-like type.

Type

ExtractDeepAgentConfig

Extract the DeepAgentTypeConfig from a DeepAgent-like type.

Type

ExtractSubAgentMiddleware

Helper type to extract middleware from a SubAgent definition.

Type

GetToolCallsType

Extract the tool call type from a StateType's messages property.

Type

InferAgentToolCalls

Extract tool calls type from an agent's tools.

Type

InferDeepAgentSubagents

Extract the Subagents array type from a DeepAgent.

Type

InferSubagentByName

Helper type to extract a subagent by name from a DeepAgent.

Type

InferSubagentNames

Extract all subagent names as a string union from a DeepAgent.

Type

InferSubagentState

Infer the state type for a specific subagent by extracting and merging

Type

IsAgentLike

Check if a type is agent-like (has ~agentTypes phantom property).

Type

IsDeepAgentLike

Check if a type is a DeepAgent (has ~deepAgentTypes phantom property).

Type

MessageMetadata

Type

SubagentStateMap

Create a map of subagent names to their state types.

Type

SubagentStatus

The execution status of a subagent.

Type

SubagentStream

Represents a single subagent stream.

Type

ToolCallFromTool

Infer a tool call type from a single tool.

Type

ToolCallsFromTools

Infer a union of tool call types from an array of tools.

Type

ToolCallState

The lifecycle state of a tool call.

Type

ToolCallWithResult

Represents a tool call paired with its result.

Type

UseStreamCustom

Type

UseStreamCustomOptions

Type

InferBag

Infer the Bag type from an agent, defaulting to the provided Bag.

Type

InferNodeNames

Infer the node names from a compiled graph.

Type

InferStateType

Infer the state type from an agent, graph, or direct state type.

Type

InferSubagentStates

Infer subagent state map from a DeepAgent.

Type

InferToolCalls

Infer tool call types from an agent.

Type

ResolveStreamInterface

Resolves the appropriate stream interface based on the agent/graph type.

Type

ResolveStreamOptions

Resolves the appropriate options interface based on the agent/graph type.

Type

MessagesStreamEvent

deprecated

Message stream event specific to LangGraph Server.