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-sdkindex
Module●Since v0.0

index

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

Functions

function
overrideFetchImplementation
function
getApiKey→ string | undefined

Classes

class
StreamError
class
Client

Interfaces

Type Aliases

View source on GitHub
interface
Assistant
interface
AssistantBase
interface
AssistantGraph
interface
AssistantsSearchResponse
interface
AssistantVersion
interface
BaseStream

Base stream interface shared by all stream types.

Contains core properties for state management, messaging, and stream control that are common to CompiledStateGraph, ReactAgent, and DeepAgent streams.

This interface provides the foundation that all stream types build upon:

  • State management (values, isLoading, error)
  • Message handling (messages)
  • Interrupt handling (interrupt)
  • Stream lifecycle (submit, stop)
  • Branching and history (branch, history)
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.

Extends UseGraphStream with tool calling capabilities. Tool calls are automatically typed based on the agent's tools configuration.

Use this interface when streaming from an agent created with createAgent. For subagent streaming capabilities, use UseDeepAgentStream with createDeepAgent.

This interface is subject to change.

interface
UseAgentStreamOptions

Options for configuring an agent stream.

Use this options interface when calling useStream with a ReactAgent created via createAgent.

This interface is subject to change.

interface
UseDeepAgentStream

Stream interface for DeepAgent instances created with createDeepAgent.

Extends UseAgentStream with subagent streaming capabilities. Subagent streams are automatically typed based on the agent's subagent configuration, enabling type-safe access to subagent state and messages.

Use this interface when streaming from an agent created with createDeepAgent that orchestrates multiple specialized subagents.

This interface is subject to change.

interface
UseDeepAgentStreamOptions

Options for configuring a deep agent stream.

Use this options interface when calling useStream with a DeepAgent created via createDeepAgent. Includes all agent options plus subagent-specific configuration.

interface
ClientConfig
typeAlias
AIMessage: BaseMessage & __type

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

typeAlias
BagTemplate

Template for the bag type.

typeAlias
Checkpoint
typeAlias
Config
typeAlias
CustomStreamEvent

Streaming custom data from inside the nodes.

typeAlias
DebugStreamEvent

Stream event with detailed debug information.

typeAlias
DefaultValues: Record<string, unknown>[] | Record<string, unknown>
typeAlias
ErrorStreamEvent

Stream event with error information.

typeAlias
EventsStreamEvent

Stream event with events occurring during execution.

typeAlias
FeedbackStreamEvent

Stream event with a feedback key to signed URL map. Set feedbackKeys in the RunsStreamPayload to receive this event.

typeAlias
FunctionMessage: BaseMessage & __type
typeAlias
HumanMessage: BaseMessage & __type
typeAlias
InferBag: T extends __type ? BagTemplate : B

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

Currently returns the provided Bag for all types. Can be extended in the future to extract Bag from agent types.

typeAlias
InferNodeNames: T extends __type ? N extends string ? Exclude<N, "__start__"> : string : string

Infer the node names from a compiled graph.

Extracts the ~NodeType phantom property from CompiledGraph instances, providing a union of all node names defined in the graph.

typeAlias
InferNodeReturnTypes: T extends __type ? R extends Record<string, unknown> ? R : Record<string, Record<string, unknown>> : Record<string, Record<string, unknown>>

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

Extracts the ~NodeReturnType phantom property from CompiledGraph instances, which is a mapped type of { [nodeName]: ReturnType } for each node.

typeAlias
InferStateType: T extends __type ? InferAgentState<T> : T extends __type ? S extends Record<string, unknown> ? S : Record<string, unknown> : T extends __type ? O extends Record<string, unknown> ? O : Record<string, unknown> : T extends Record<string, unknown> ? T : Record<string, unknown>
typeAlias
InferSubagentStates: T extends __type ? SubagentStateMap<T, InferAgentToolCalls<T>> : DefaultSubagentStates

Infer subagent state map from a DeepAgent.

For DeepAgent, creates a map of subagent names to their state types. For non-DeepAgent, returns DefaultSubagentStates.

typeAlias
InferToolCalls: T extends __type ? InferAgentToolCalls<T> : DefaultToolCall

Infer tool call types from an agent.

For agents, extracts typed tool calls from the agent's tools. For non-agents, returns DefaultToolCall.

typeAlias
Message: HumanMessage | AIMessage<ToolCall> | ToolMessage | SystemMessage | FunctionMessage | RemoveMessage

Union of all message types.

typeAlias
MessagesTupleStreamEvent

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

typeAlias
Metadata: Optional<__type>
typeAlias
MetadataStreamEvent

Metadata stream event with information about the run and thread

typeAlias
OnConflictBehavior: "raise" | "do_nothing"
typeAlias
RemoveMessage: BaseMessage & __type
typeAlias
ResolveStreamInterface: IsDeepAgent<T> extends true ? UseDeepAgentStream<InferStateType<T>, InferToolCalls<T>, InferSubagentStates<T>, Bag> : IsReactAgent<T> extends true ? UseAgentStream<InferStateType<T>, InferToolCalls<T>, Bag> : UseDeepAgentStream<InferStateType<T>, InferToolCalls<T>, DefaultSubagentStates, Bag>

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

This type automatically selects the correct stream interface based on the type of agent or graph passed to useStream:

  1. DeepAgent (~deepAgentTypes) → UseDeepAgentStream

    • Includes: values, messages, toolCalls, subagents, getSubagentsByType, getSubagentsByMessage
  2. ReactAgent (~agentTypes) → UseAgentStream

    • Includes: values, messages, toolCalls, getToolCalls
    • Excludes: subagents, getSubagentsByType
  3. CompiledGraph / Default → UseDeepAgentStream with DefaultSubagentStates

    • Includes: values, messages, submit, stop, toolCalls, subagents
    • SubagentStates defaults to DefaultSubagentStates (loosely typed)
typeAlias
ResolveStreamOptions: IsDeepAgent<T> extends true ? UseDeepAgentStreamOptions<InferStateType<T>, Bag> : IsReactAgent<T> extends true ? UseAgentStreamOptions<InferStateType<T>, Bag> : UseStreamOptions<InferStateType<T>, Bag>

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

This type automatically selects the correct options interface based on the type of agent or graph:

  1. DeepAgent → UseDeepAgentStreamOptions

    • Includes: filterSubagentMessages option
  2. ReactAgent → UseAgentStreamOptions

  3. CompiledGraph / Default → UseGraphStreamOptions

typeAlias
StreamMode: "values" | "messages" | "updates" | "events" | "debug" | "tasks" | "checkpoints" | "custom" | "messages-tuple"

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

  • Stream modes
    • "values": Stream only the state values.
    • "messages": Stream complete messages.
    • "messages-tuple": Stream (message chunk, metadata) tuples.
    • "updates": Stream updates to the state.
    • "events": Stream events occurring during execution.
    • "debug": Stream detailed debug information.
    • "custom": Stream custom events.
typeAlias
SystemMessage: BaseMessage & __type
typeAlias
ThreadStatus: "idle" | "busy" | "interrupted" | "error"
typeAlias
ToolMessage: BaseMessage & __type
typeAlias
UpdatesStreamEvent

Stream event with updates to the state after each step. The streamed outputs include the name of the node that produced the update as well as the update.

typeAlias
ValuesStreamEvent

Stream event with values after completion of each step.

typeAlias
RequestHook: (url: URL, init: RequestInit)
deprecatedtypeAlias
MessagesStreamEvent: MessagesMetadataStreamEvent | MessagesCompleteStreamEvent | MessagesPartialStreamEvent

Message stream event specific to LangGraph Server.

Overrides the fetch implementation used for LangSmith calls. You should use this if you need to use an implementation of fetch other than the default global (e.g. for dealing with proxies).

Get the API key from the environment. Precedence:

  1. explicit argument (if string)
  2. LANGGRAPH_API_KEY
  3. LANGSMITH_API_KEY
  4. LANGCHAIN_API_KEY

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

Detection order:

  1. Agent-like (~agentTypes) → InferAgentState
  2. CompiledGraph (~RunOutput) → Extract RunOutput
  3. Pregel (~OutputType) → Extract OutputType
  4. Direct state type → Return as-is