This repository contains the JS/TS SDK for interacting with the LangGraph REST API.
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);
}
To generate documentation, run the following commands:
Generate docs.
pnpm typedoc
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
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
The reference documentation is available here.
More usage examples can be found here.
The change log for new versions can be found here.
Transport used to stream the thread.
Manages subagent execution state.
Framework-agnostic orchestrator for custom transport streams.
Transport used to stream the thread.
Tracks pending server-side runs created via multitaskStrategy: "enqueue".
Framework-agnostic orchestrator for LangGraph Platform streams.
Manages subagent execution state.
Check if the provided user was provided by LangGraph Studio.
Get the API key from the environment.
Strip headless-tool interrupts from a user-facing interrupt list.
Execute and resume all newly seen headless-tool interrupts from a values
Overrides the fetch implementation used for LangSmith calls.
Parses a headless-tool interrupt value from the graph. Accepts both
Get the API key from the environment.
Retrieves the global logger instance for LangGraph Platform.
Calculates the depth of a subagent based on its namespace.
Extracts the parent tool call ID from a namespace.
Extracts the tool call ID from a namespace path.
Strip headless-tool interrupts from a user-facing interrupt list.
Execute and resume all newly seen headless-tool interrupts from a values
Checks if a namespace indicates a subagent/subgraph message.
Parses a headless-tool interrupt value from the graph. Accepts both
Helper to send and persist UI messages. Accepts a map of component names to React components
Calculates the depth of a subagent based on its namespace.
Converts plain message objects within each history state's values
Ensures all messages in an array are BaseMessage class instances.
Extracts the parent tool call ID from a namespace.
Extracts the tool call ID from a namespace path.
Checks if a namespace indicates a subagent/subgraph message.
If value looks like a HITL request object, expose both the new camelCase
Normalizes HITL interrupt payloads to expose camelCase fields plus deprecated
Applies normalizeInterruptForClient to each interrupt.
Returns true when onFinish declares at least one parameter and therefore
Identity converter that keeps @langchain/core class instances.