### start Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/AsyncBatchedStore/start Starts the store. This method can be overridden if custom initialization is needed. ```APIDOC ## start ### Description Starts the store. Override if initialization is needed. ### Method start() ### Endpoint N/A (SDK method) ### Parameters None ### Request Example ```javascript start() ``` ### Response N/A (This is an initialization method, typically returns void or a promise resolving to void) ### Error Handling N/A ``` -------------------------------- ### Basic Key-Value Storage Example Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/InMemoryStore Demonstrates the basic usage of InMemoryStore for putting and getting key-value pairs. ```APIDOC ## Example: Basic Key-Value Storage ### Description This example shows how to instantiate `InMemoryStore` and use its `put` and `get` methods for basic key-value operations. ### Code ```typescript // Basic key-value storage const store = new InMemoryStore(); await store.put(["users", "123"], "prefs", { theme: "dark" }); const item = await store.get(["users", "123"], "prefs"); ``` ``` -------------------------------- ### BaseStore Start Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/BaseStore/start The start method initializes the store. It can be overridden to provide custom initialization logic. It returns void or a Promise. ```typescript start(): void | Promise ``` -------------------------------- ### Start the AsyncBatchedStore Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/AsyncBatchedStore/start Call this method to start the store. Override if custom initialization logic is required. ```typescript start() ``` -------------------------------- ### MemoryStore.start() Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/MemoryStore/start Starts the MemoryStore. This method can be overridden if custom initialization logic is required. ```APIDOC ## MemoryStore.start() ### Description Starts the store. Override if initialization is needed. ### Method `start(): void | Promise` ### Parameters This method does not accept any parameters. ### Response Returns `void` or a `Promise` if the initialization is asynchronous. ``` -------------------------------- ### start Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/StreamManager/start This is the TypeScript signature for the start method. It outlines the parameters and return type for initiating a LangGraph process. ```typescript start( action: (signal: AbortSignal) => Promise, GetCustomEventType>, any, any>>, options: __type, startOptions: __type ): Promise ``` -------------------------------- ### Example Usage Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-postgres/index/PostgresSaver Demonstrates how to instantiate and use the PostgresSaver with a LangGraph agent, including setting up the checkpointer and invoking the graph. ```APIDOC ## Example Usage ### Description This example shows how to integrate the `PostgresSaver` with a LangGraph agent. It covers initializing the checkpointer with a connection string, setting up the necessary database schema, and then using the checkpointer with a `createReactAgent`. ### Code Snippet ```typescript import { ChatOpenAI } from "@langchain/openai"; import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres"; import { createReactAgent } from "@langchain/langgraph/prebuilt"; // Initialize the checkpointer with a connection string and optional configuration const checkpointer = PostgresSaver.fromConnString( "postgresql://user:password@localhost:5432/db", // optional configuration object { schema: "custom_schema" // defaults to "public" } ); // NOTE: you need to call .setup() the first time you're using your checkpointer await checkpointer.setup(); // Create a LangGraph agent using the configured checkpointer const graph = createReactAgent({ tools: [getWeather], // Assuming getWeather is a defined tool llm: new ChatOpenAI({ model: "gpt-4o-mini", }), checkpointSaver: checkpointer, }); // Define configuration for the graph invocation, including a thread ID const config = { configurable: { thread_id: "1" } }; // Invoke the graph with user messages and the configuration await graph.invoke({ messages: [{ role: "user", content: "what's the weather in sf" }], }, config); ``` ``` -------------------------------- ### Initialize SqliteSaver Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-sqlite/SqliteSaver/setup Call the setup() function to initialize the SqliteSaver. This is typically the first step before using its other functionalities. ```javascript setup() ``` -------------------------------- ### setup Method Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-postgres/index/PostgresSaver Initializes the database schema and tables required by the PostgresSaver. This method must be called before using other methods of the checkpointer. ```APIDOC ## Method: setup ### Description Initializes the database schema and tables required by the PostgresSaver. This method must be called before using other methods of the checkpointer. ### Signature ```javascript async setup(): Promise ``` ### Parameters None ### Request Example ```typescript // NOTE: you need to call .setup() the first time you're using your checkpointer await checkpointer.setup(); ``` ### Response #### Success Response (200) - `void` ``` -------------------------------- ### StateGraph Example Source: https://reference.langchain.com/javascript/langchain-langgraph/web/StateGraph Demonstrates how to define a state with annotations, add nodes, and compile a StateGraph for invocation. ```APIDOC ## Example Usage ```ts import { type BaseMessage, AIMessage, HumanMessage, } from "@langchain/core/messages"; import { StateGraph, Annotation } from "@langchain/langgraph"; // Define a state with a single key named "messages" that will // combine a returned BaseMessage or arrays of BaseMessages const StateAnnotation = Annotation.Root({ sentiment: Annotation, messages: Annotation({ // Define the 'messages' key with an array of BaseMessage reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => { // Reducer function to combine messages if (Array.isArray(right)) { return left.concat(right); } return left.concat([right]); }, default: () => [], // Default value for 'messages' is an empty array }), }); const graphBuilder = new StateGraph(StateAnnotation); // A node in the graph that returns an object with a "messages" key // will update the state by combining the existing value with the returned one. const myNode = (state: typeof StateAnnotation.State) => { return { messages: [new AIMessage("Some new response")], sentiment: "positive", }; }; const graph = graphBuilder .addNode("myNode", myNode) .addEdge("__start__", "myNode") .addEdge("myNode", "__end__") .compile(); await graph.invoke({ messages: [new HumanMessage("how are you?")] }); // Expected output: // { // messages: [HumanMessage("how are you?"), AIMessage("Some new response")], // sentiment: "positive", // } ``` ``` -------------------------------- ### beforeAll Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-validation/index/CheckpointSaverTestInitializer/beforeAll This is the signature for the beforeAll method. It indicates that the method can either return nothing (void) or a Promise that resolves when the setup is finished. Use this for any prerequisite setup your tests might need. ```typescript beforeAll(): void | Promise ``` -------------------------------- ### start Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/StreamManager/start Initiates the StreamManager. This method takes an action function, which is responsible for generating the event stream, and configuration options. ```APIDOC ## start ### Description Starts the StreamManager with a given action and options. ### Method Signature ```typescript start( action: (signal: AbortSignal) => Promise, GetCustomEventType>, any, any>>, options: __type, startOptions?: __type ): Promise ``` ### Parameters #### `action` * **Type**: `(signal: AbortSignal) => Promise, GetCustomEventType>, any, any>>` * **Description**: The function that generates the asynchronous event stream. It receives an AbortSignal for cancellation. #### `options` * **Type**: `__type` * **Description**: Configuration options for the StreamManager. #### `startOptions` * **Type**: `__type` * **Description**: Optional additional options for starting the StreamManager. ``` -------------------------------- ### get() Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/StateModule Retrieves the current state. ```APIDOC ## get() ### Description Retrieves the current state. ### Method (Not specified, likely a method call on the StateModule instance) ### Endpoint (Not applicable for SDK methods) ### Parameters (No parameters explicitly documented) ### Request Example (Not applicable for SDK methods) ### Response #### Success Response (Type and description not explicitly documented, likely returns the current state object) #### Response Example (Not applicable for SDK methods) ``` -------------------------------- ### Example Usage Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/react/UseDeepAgentStream Demonstrates how to use `createDeepAgent` and `useStream` in a React component, including how to access and utilize typed subagent streams. ```typescript import { createDeepAgent } from "deepagents"; import { useStream } from "@langchain/langgraph-sdk/react"; // Define subagents with typed middleware const agent = createDeepAgent({ subagents: [ { name: "researcher", description: "Research specialist", // middleware: [ResearchMiddleware], }, { name: "writer", description: "Content writer", // middleware: [WriterMiddleware], }, ] as const, // Important: use 'as const' for type inference }); // In React component: function Chat() { const stream = useStream({ assistantId: "deep-agent", apiUrl: "http://localhost:2024", filterSubagentMessages: true, // Only show main agent messages }); // Subagent streams are typed! const researchers = stream.getSubagentsByType("researcher"); researchers.forEach(subagent => { // subagent.values.messages is typed as Message[] // subagent.status is "pending" | "running" | "complete" | "error" console.log("Researcher status:", subagent.status); }); // Track all active subagents stream.activeSubagents.forEach(subagent => { console.log(`${subagent.toolCall.args.subagent_type} is running...`); }); return (
{/* Render chat messages, etc. */}
); } ``` -------------------------------- ### init Source: https://reference.langchain.com/javascript/langchain-langgraph/index/NativeStreamTransformer/init Initializes the transformer. This method is called once before the run starts. ```APIDOC ## init ### Description Called once before the run starts. ### Signature ```typescript init(): TProjection ``` ``` -------------------------------- ### Writing to Multiple Channels Source: https://reference.langchain.com/javascript/langchain-langgraph/pregel/Channel/writeTo Example demonstrating how to use writeTo to send output to multiple specified channels. ```typescript // Write to multiple channels const write = Channel.writeTo(["output", "state"]); ``` -------------------------------- ### Writing with Specific Values Source: https://reference.langchain.com/javascript/langchain-langgraph/pregel/Channel/writeTo Example showing how to use writeTo to send output to a channel with specific predefined values. ```typescript // Write with specific values const write = Channel.writeTo(["output"], { state: "completed", result: calculateResult() }); ``` -------------------------------- ### getClient Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/OrchestratorAccessors/getClient This method returns the singleton client instance. It is recommended to call this method to get the client. ```APIDOC ## getClient ### Description Retrieves the singleton client instance for LangChain. ### Method Signature ```typescript getClient(): Client ``` ### Returns - **Client**: The singleton client instance. ``` -------------------------------- ### Streaming Events from a Runnable Source: https://reference.langchain.com/javascript/langchain-langgraph/remote/RemoteGraph/streamEvents Demonstrates how to use streamEvents to get progress updates and custom events from a Runnable. This example includes a placeholder for a slow operation and logs custom events to the console. ```typescript import { RunnableLambda } from "@langchain/core/runnables"; import { dispatchCustomEvent } from "@langchain/core/callbacks/dispatch"; // Use this import for web environments that don't support "async_hooks" // and manually pass config to child runs. // import { dispatchCustomEvent } from "@langchain/core/callbacks/dispatch/web"; const slowThing = RunnableLambda.from(async (someInput: string) => { // Placeholder for some slow operation await new Promise((resolve) => setTimeout(resolve, 100)); await dispatchCustomEvent("progress_event", { message: "Finished step 1 of 2", }); await new Promise((resolve) => setTimeout(resolve, 100)); return "Done"; }); const eventStream = await slowThing.streamEvents("hello world", { version: "v2", }); for await (const event of eventStream) { if (event.event === "on_custom_event") { console.log(event); } } ``` -------------------------------- ### submitRun Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/ThreadStream/submitRun Starts a run without the v1 eager lazy-getter shims. Callers that manage their own content subscriptions get the narrow union filter they asked for. Lifecycle/interrupt tracking is served by a dedicated watcher. ```APIDOC ## submitRun ### Description Starts a run without the v1 eager lazy-getter shims. Callers that manage their own content subscriptions (such as `StreamController`) get the narrow union filter they asked for. Lifecycle / interrupt tracking is instead served by the dedicated `#startLifecycleWatcher`, which opens a wildcard `["lifecycle", "input"]` stream alongside the narrow content pump on both SSE and WebSocket transports. ### Method Signature `submitRun(params: __type): Promise` ### Parameters #### Path Parameters - **params** (`__type`) - Required - Description for params ### Response #### Success Response - **RunResult** - The result of the run. ``` -------------------------------- ### setup Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-postgres/index/PostgresSaver/setup Sets up the checkpoint database asynchronously. This method creates necessary tables and runs migrations. It must be called by the user the first time the checkpointer is used. ```APIDOC ## setup ### Description Sets up the checkpoint database asynchronously. This method creates the necessary tables in the Postgres database if they don't already exist and runs database migrations. It MUST be called directly by the user the first time checkpointer is used. ### Method setup() ### Returns Promise ``` -------------------------------- ### Initialize and Use PostgresSaver Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-postgres/index/PostgresSaver Demonstrates how to initialize the PostgresSaver using a connection string and optional configuration, set up the database schema, and integrate it with a LangGraph agent. ```typescript import { ChatOpenAI } from "@langchain/openai"; import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres"; import { createReactAgent } from "@langchain/langgraph/prebuilt"; const checkpointer = PostgresSaver.fromConnString( "postgresql://user:password@localhost:5432/db", // optional configuration object { schema: "custom_schema" // defaults to "public" } ); // NOTE: you need to call .setup() the first time you're using your checkpointer await checkpointer.setup(); const graph = createReactAgent({ tools: [getWeather], llm: new ChatOpenAI({ model: "gpt-4o-mini", }), checkpointSaver: checkpointer, }); const config = { configurable: { thread_id: "1" } }; await graph.invoke({ messages: [{ role: "user", content: "what's the weather in sf" }], }, config); ``` -------------------------------- ### Extracting Tool Calls with GetToolCallsType Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/react/GetToolCallsType Define a state with typed messages and use GetToolCallsType to infer the tool call type. This example demonstrates the canonical way to get typed tool calls. ```typescript type MyToolCalls = | { name: "get_weather"; args: { location: string }; id?: string } | { name: "search"; args: { query: string }; id?: string }; interface MyState { messages: Message[]; } // GetToolCallsType = MyToolCalls ``` -------------------------------- ### get Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/StateModule/get The `get` method retrieves state using `StateGetParams` and returns a `Promise` of `StateGetResult`. ```APIDOC ## get ### Description Retrieves state from the StateModule. ### Method ``` get(params: StateGetParams): Promise ``` ### Parameters #### Path Parameters - `params` (StateGetParams) - Required - Parameters for retrieving state. ### Response #### Success Response - `StateGetResult` - The result of the state retrieval. ``` -------------------------------- ### Asynchronous Setup for PostgresSaver Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-postgres/index/PostgresSaver/setup This method initializes the Postgres database for checkpointing. It creates required tables and runs migrations if they do not exist. It must be called by the user before the first use of the checkpointer. ```typescript setup(): Promise ``` -------------------------------- ### Respond with options for configuration and metadata Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/stream/StreamController/respond Provide options to specify configuration (like model) and metadata (like source) for the run that services the resume. ```javascript await controller.respond( { approved: true }, { config: { configurable: { model: "gpt-4o" } }, metadata: { source: "ui" } }, ); ``` -------------------------------- ### get Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/MessageTupleManager/get This is the TypeScript signature for the get method. It retrieves an item by its ID or a default index. ```typescript get(id: string | null | undefined, defaultIndex: number): __type | null ``` -------------------------------- ### Get Current Barrier Value Source: https://reference.langchain.com/javascript/langchain-langgraph/index/DynamicBarrierValue/get Call the get() method to retrieve the current value of the channel. This method is available since v0.3. ```javascript get() ``` -------------------------------- ### Create PostgresSaver from Connection String Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-postgres/index/PostgresSaver/fromConnString Use this method to initialize a PostgresSaver instance by providing a PostgreSQL connection string and optional configuration. The `setup()` method must be called to ensure the necessary database schema is in place. ```typescript const connString = "postgresql://user:password@localhost:5432/db"; const checkpointer = PostgresSaver.fromConnString(connString, { schema: "custom_schema" // defaults to "public" }); await checkpointer.setup(); ``` -------------------------------- ### RedisStore get Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-redis/store/RedisStore/get This is the TypeScript signature for the get method. It retrieves an item from the Redis store based on namespace and key. ```typescript get(namespace: string[], key: string, options: __type): Promise ``` -------------------------------- ### Get Graph Representation Source: https://reference.langchain.com/javascript/langchain-langgraph/index/CompiledGraph/getGraph Use this method to get a drawable representation of the computation graph. Note that this method is deprecated and `getGraphAsync` should be used instead. ```javascript getGraph(config?: RunnableConfig> & __type): Graph ``` -------------------------------- ### prepareFetchOptions Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/BaseClient/prepareFetchOptions Prepares the URL and RequestInit object for making fetch requests. It takes a path and an optional RequestInit object, returning a tuple containing the final URL and the modified RequestInit object. ```APIDOC ## prepareFetchOptions ### Description Prepares the URL and RequestInit object for making fetch requests. It takes a path and an optional RequestInit object, returning a tuple containing the final URL and the modified RequestInit object. ### Signature ```typescript prepareFetchOptions(path: string, options: RequestInit __type): [URL, RequestInit] ``` ### Parameters #### Path Parameters * **path** (string) - Required - The path for the fetch request. * **options** (RequestInit & __type) - Optional - Additional fetch options to merge. ### Returns * **[URL, RequestInit]** - A tuple containing the URL and the RequestInit object. ``` -------------------------------- ### StateModule get Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/StateModule/get This is the TypeScript signature for the get method in the StateModule. It takes StateGetParams as input and returns a Promise resolving to StateGetResult. ```typescript get(params: StateGetParams): Promise ``` -------------------------------- ### Example Usage of withConfig Source: https://reference.langchain.com/javascript/langchain-langgraph/pregel/Pregel/withConfig Demonstrates how to create new Pregel graph instances with specific configurations, such as enabling debug mode or setting a thread ID. ```typescript // Create a new instance with debug enabled const debugGraph = graph.withConfig({ debug: true }); // Create a new instance with a specific thread ID const threadGraph = graph.withConfig({ configurable: { thread_id: "123" } }); ``` -------------------------------- ### Get Current Channel Value Source: https://reference.langchain.com/javascript/langchain-langgraph/index/Topic/get Use the `get()` method to retrieve the current value of a channel. This is useful for inspecting the state of a graph at any point during its execution. ```typescript get(): Value[] ``` -------------------------------- ### Create and Stream with createReactAgent Source: https://reference.langchain.com/javascript/langchain-langgraph/prebuilt/createReactAgent This example demonstrates how to create a React agent using createReactAgent, define a tool, and then stream the agent's execution with specific inputs. It shows how to process the streamed messages. ```typescript import { ChatOpenAI } from "@langchain/openai"; import { tool } from "@langchain/core/tools"; import { z } from "zod"; import { createReactAgent } from "@langchain/langgraph/prebuilt"; const model = new ChatOpenAI({ model: "gpt-4o", }); const getWeather = tool((input) => { if (["sf", "san francisco"].includes(input.location.toLowerCase())) { return "It's 60 degrees and foggy."; } else { return "It's 90 degrees and sunny."; } }, { name: "get_weather", description: "Call to get the current weather.", schema: z.object({ location: z.string().describe("Location to get the weather for."), }) }) const agent = createReactAgent({ llm: model, tools: [getWeather] }); const inputs = { messages: [{ role: "user", content: "what is the weather in SF?" }], }; const stream = await agent.stream(inputs, { streamMode: "values" }); for await (const { messages } of stream) { console.log(messages); } // Returns the messages in the state at each step of execution ``` -------------------------------- ### START Reserved Node Name Source: https://reference.langchain.com/javascript/langchain-langgraph/web/START This snippet shows the special reserved node name used to denote the start of a LangGraph graph. It is a constant string value. ```javascript START: "__start__" ``` -------------------------------- ### get Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/BaseCheckpointSaver/get This is the TypeScript signature for the get method. It indicates the method takes a config object of type RunnableConfig and returns a Promise resolving to a Checkpoint or undefined. ```typescript get(config: RunnableConfig): Promise | undefined> ``` -------------------------------- ### Client Constructor Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/Client/constructor Initializes a new instance of the Client class. This constructor accepts a configuration object to set up the client with specific state, update, and event types. ```APIDOC ## constructor(config: ClientConfig): Client ### Description Initializes a new instance of the Client class. ### Parameters #### Parameters - **config** (ClientConfig) - Required - Configuration object for the client. ``` -------------------------------- ### Start Lifecycle Watcher Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/ThreadStream/startLifecycleWatcher Call this method to start the wildcard lifecycle watcher. It is idempotent and can be used when you know the thread already exists server-side to proactively open the SSE stream. ```typescript startLifecycleWatcher() ``` -------------------------------- ### Get Stream Writer from Config Source: https://reference.langchain.com/javascript/langchain-langgraph/index/getWriter Use this utility to get the stream writer when custom streaming is enabled in the LangGraph runnable configuration. It returns undefined if custom streaming is not configured. ```javascript getWriter(config?: LangGraphRunnableConfig>): (chunk: unknown) => void | undefined ``` -------------------------------- ### constructor Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/MemoryStore/constructor Initializes a new instance of the MemoryStore class. ```APIDOC ## constructor ### Description Initializes a new instance of the MemoryStore class. ### Method constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Name| Type| Description ---|---|--- `options`| `__type`| ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### StoreClient Constructor Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/StoreClient/constructor Initializes a new instance of the StoreClient class. The constructor accepts a configuration object that specifies how the client should be set up. ```APIDOC ## constructor StoreClient ### Description Initializes a new instance of the StoreClient class. ### Method constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **config** (`ClientConfig`) - Required - Configuration object for the StoreClient. ``` -------------------------------- ### AsyncBatchedStore get Method Signature Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/AsyncBatchedStore/get This is the TypeScript signature for the get method. It specifies the types for the namespace (an array of strings) and the key (a string), and indicates that it returns a Promise resolving to an Item object or null. ```typescript get(namespace: string[], key: string): Promise ``` -------------------------------- ### constructor Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/MediaAssembler/constructor Initializes a new instance of the MediaAssembler class. The constructor accepts an optional options object to configure the assembler. ```APIDOC ## constructor ### Description Initializes a new instance of the MediaAssembler class. The constructor accepts an optional options object to configure the assembler. ### Method constructor ### Parameters #### Parameters - **options** (MediaAssemblerOptions) - Optional - Default: `{}` - Configuration options for the MediaAssembler. ``` -------------------------------- ### AssistantsClient Constructor Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/AssistantsClient/constructor Initializes a new instance of the AssistantsClient. The constructor takes a single configuration object as a parameter. ```APIDOC ## constructor AssistantsClient ### Description Initializes a new instance of the AssistantsClient. The constructor takes a single configuration object as a parameter. ### Signature ```typescript constructor(config: ClientConfig): AssistantsClient ``` ### Parameters #### Path Parameters - **config** (ClientConfig) - Description: Configuration object for the client. ``` -------------------------------- ### Filter Lifecycle Entries by Namespace Source: https://reference.langchain.com/javascript/langchain-langgraph/index/filterLifecycleEntries Use this function to create a filtered stream of lifecycle entries. Specify the log, the namespace path to filter by, and optionally a starting index to control the iteration start point. ```typescript filterLifecycleEntries(log: EventLog, path: Namespace, startAt: number = 0): AsyncIterable ``` -------------------------------- ### prepareFetchOptions() Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/BaseClient Prepares the options for a fetch request, potentially including headers and other configurations. ```APIDOC ## prepareFetchOptions() ### Description Prepares the options for a fetch request, potentially including headers and other configurations. ### Method Not specified, but likely a method within the BaseClient class. ### Parameters Not specified in the source. ### Request Example Not specified in the source. ### Response Not specified in the source. ``` -------------------------------- ### attachEdge Source: https://reference.langchain.com/javascript/langchain-langgraph/index/CompiledGraph/attachEdge Attaches an edge between a start node and an end node in a compiled graph. The start and end nodes can be special keywords like "__start__" or "__end__", or other node identifiers. ```APIDOC ## attachEdge ### Description Attaches an edge between a start node and an end node in a compiled graph. The start and end nodes can be special keywords like "__start__" or "__end__", or other node identifiers. ### Method `attachEdge(start: "__start__" | N, end: "__end__" | N)` ### Parameters #### Path Parameters - **start** ("__start__" | N) - Required - The starting node of the edge. - **end** ("__end__" | N) - Required - The ending node of the edge. ### Returns `void` ``` -------------------------------- ### prepareFetchOptions Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/AssistantsClient/prepareFetchOptions Prepares the URL and RequestInit object for making fetch requests. This is a utility function used internally for constructing API requests. ```APIDOC ## prepareFetchOptions ### Description Prepares the URL and RequestInit object for making fetch requests. This is a utility function used internally for constructing API requests. ### Signature ```typescript prepareFetchOptions(path: string, options: RequestInit __type): [URL, RequestInit] ``` ### Parameters #### Path Parameters * **path** (string) - Required - The path for the API request. * **options** (RequestInit & __type) - Optional - The initial request options to be merged. ### Returns A tuple containing the URL and the prepared RequestInit object. ``` -------------------------------- ### StateSchema Example Usage Source: https://reference.langchain.com/javascript/langchain-langgraph/web/StateSchema Demonstrates how to instantiate and use the StateSchema class with Zod schemas to define complex agent states, including prebuilt values, basic values, and reduced values. ```APIDOC ## StateSchema Example ### Description This example shows how to define an agent's state using `StateSchema` and various Zod types, including `MessagesValue`, `z.string()`, `z.number().default()`, and `ReducedValue` for managing history. ### Code ```ts import { z } from "zod"; import { StateSchema, ReducedValue, MessagesValue } from "@langchain/langgraph"; const AgentState = new StateSchema({ // Prebuilt messages value messages: MessagesValue, // Basic LastValue channel from any standard schema currentStep: z.string(), // LastValue with native default count: z.number().default(0), // ReducedValue for fields needing reducers history: new ReducedValue( z.array(z.string()).default(() => []), { inputSchema: z.string(), reducer: (current, next) => [...current, next], } ), }); // Extract types type State = typeof AgentState.State; type Update = typeof AgentState.Update; // Use in StateGraph // const graph = new StateGraph(AgentState); ``` ### Usage Notes - `MessagesValue` is a prebuilt schema for message history. - `z.string()` and `z.number().default(0)` define basic string and number fields with a default value. - `ReducedValue` is used for fields that require a reducer function to combine new values with existing ones, such as accumulating history. ``` -------------------------------- ### get Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/MessageTupleManager Retrieves all messages currently managed. ```APIDOC ## get() ### Description Returns the current list of all messages that have been added to the manager. ### Method get ### Parameters None ### Response #### Success Response (200) - **chunks** (Array) - The array of messages currently managed. ``` -------------------------------- ### get() Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/ChannelProtocol Retrieves the current value of the channel. ```APIDOC ## get() ### Description Retrieves the current value of the channel. ### Method (Implicitly called by the LangGraph runtime) ### Parameters None explicitly documented for this method signature. ### Response - **value** (ValueType) - The current value of the channel. ### Request Example (Not applicable for this method as it's part of the interface contract) ### Response Example (Not applicable for this method as it's part of the interface contract) ``` -------------------------------- ### submitDirect Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/StreamOrchestrator/submitDirect Submits input values directly to the LangGraph Platform, creating a new thread if necessary. Starts a streaming run and processes events until completion. Unlike submit, this does not handle queueing — if a stream is already active, a concurrent run will be started. ```APIDOC ## submitDirect ### Description Submit input values directly to the LangGraph Platform, creating a new thread if necessary. Starts a streaming run and processes events until completion. Unlike submit, this does not handle queueing — if a stream is already active, a concurrent run will be started. ### Method Signature ```typescript submitDirect( values: StateType, submitOptions: SubmitOptions> ): Promise ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **values** (*StateType*) - Required - The state values to send as run input. * **submitOptions** (*SubmitOptions>*) - Optional - Optional configuration for the run (config, checkpoint, multitask strategy, optimistic values, etc.). ### Request Example ```json { "values": { /* StateType object */ }, "submitOptions": { /* SubmitOptions object */ } } ``` ### Response #### Success Response (200) * **void** - The operation completes successfully. #### Response Example None (Promise resolves to void) ``` -------------------------------- ### BaseStore Constructor Source: https://reference.langchain.com/javascript/langchain-langgraph/index/BaseStore/constructor Initializes a new instance of the BaseStore class. ```APIDOC ## BaseStore constructor ### Description Initializes a new instance of the BaseStore class. This is the base class for all state stores in LangGraph. ### Signature ```javascript constructor(): BaseStore ``` ### Returns - **BaseStore** - An instance of the BaseStore class. ``` -------------------------------- ### Initialize StateGraph with State Schema and Options Source: https://reference.langchain.com/javascript/langchain-langgraph/index/StateGraph/constructor Create a StateGraph by providing a full state schema along with input and output schemas in the options. ```typescript const graph = new StateGraph({ state: FullStateSchema, input: InputSchema, output: OutputSchema, }); ``` -------------------------------- ### run Source: https://reference.langchain.com/javascript/langchain-langgraph/prebuilt/ToolNode/run Executes the runnable with the given input and configuration. ```APIDOC ## run ### Description Executes the runnable with the given input and configuration. ### Method Signature `run(input: unknown, config: RunnableConfig): Promise` ### Parameters #### Parameters - **input** (unknown) - Required - The input to the runnable. - **config** (RunnableConfig) - Required - The configuration for the runnable. ``` -------------------------------- ### toAsyncIterable Source: https://reference.langchain.com/javascript/langchain-langgraph/index/EventLog/toAsyncIterable Creates an AsyncIterable from the EventLog. You can specify the starting index for the iterable. ```APIDOC ## toAsyncIterable ### Description Creates an AsyncIterable backed by this channel, starting from startAt. ### Method Signature ```typescript toAsyncIterable(startAt: number = 0): AsyncIterable ``` ### Parameters #### Path Parameters - **startAt** (number) - Optional - Default: 0. The starting index for the iterable. ``` -------------------------------- ### constructor Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/ProtocolWebSocketTransportAdapter/constructor Initializes a new instance of the ProtocolWebSocketTransportAdapter. ```APIDOC ## constructor ### Description Initializes a new instance of the ProtocolWebSocketTransportAdapter. ### Signature ```typescript constructor(options: ProtocolWebSocketTransportOptions): ProtocolWebSocketTransportAdapter ``` ### Parameters #### `options` - **Type**: `ProtocolWebSocketTransportOptions` - **Description**: Options for the WebSocket transport. - **Required**: Yes ``` -------------------------------- ### get(index: number): T Source: https://reference.langchain.com/javascript/langchain-langgraph/index/EventLog/get Returns the item at the given zero-based index. ```APIDOC ## get(index: number): T ### Description Returns the item at the given zero-based index. ### Parameters #### Path Parameters - **index** (number) - Required - The zero-based index of the item to retrieve. ``` -------------------------------- ### getState Source: https://reference.langchain.com/javascript/langchain-langgraph/index/CompiledGraph/getState Gets the current state of the graph. Requires a checkpointer to be configured. ```APIDOC ## getState ### Description Gets the current state of the graph. Requires a checkpointer to be configured. ### Method `getState` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **config** (`RunnableConfig`) - Required - Configuration for retrieving the state - **options** (`GetStateOptions`) - Optional - Additional options ### Returns `Promise` - A snapshot of the current graph state ``` -------------------------------- ### StateGraphInit Source: https://reference.langchain.com/javascript/langchain-langgraph/index/StateGraphInit This documentation describes the StateGraphInit type, which is used for initializing a StateGraph. It outlines the available properties for configuring the graph's state and behavior. ```APIDOC ## StateGraphInit ### Description Initialization options for StateGraph. Accepts any combination of schema types for state/input/output. Supports both `state` and `stateSchema` as aliases for backward compatibility. If only `input` is provided (no state/stateSchema), `input` is used as the state schema. ### Properties - `context`: (Type not specified) - Description not specified. - `input`: (Type not specified) - Description not specified. - `interrupt`: (Type not specified) - Description not specified. - `nodes`: (Type not specified) - Description not specified. - `output`: (Type not specified) - Description not specified. - `state`: (Type not specified) - Description not specified. - `stateSchema`: (Type not specified) - Description not specified. - `writer`: (Type not specified) - Description not specified. ``` -------------------------------- ### get Source: https://reference.langchain.com/javascript/langchain-langgraph/index/DynamicBarrierValue/get Returns the current value of the channel. This method is part of the DynamicBarrierValue interface. ```APIDOC ## get ### Description Return the current value of the channel. ### Method get() ### Endpoint Not applicable (SDK method) ### Parameters None ### Request Example ``` get() ``` ### Response #### Success Response - **value** (any) - The current value of the channel. #### Response Example ```json { "value": "current_channel_value" } ``` ``` -------------------------------- ### PostgresStore Constructor Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-postgres/store/PostgresStore/constructor Initializes a new instance of the PostgresStore class. ```APIDOC ## constructor PostgresStore ### Description Initializes a new instance of the PostgresStore class. ### Method constructor ### Parameters #### Parameters - **config** (PostgresStoreConfig) - Required - Configuration object for the PostgresStore. ``` -------------------------------- ### get Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/AssistantsClient/get Retrieves an assistant by its ID. This method is available since version 0.0. ```APIDOC ## get ### Description Get an assistant by ID. ### Method `get` ### Parameters #### Path Parameters - **assistantId** (string) - Required - The ID of the assistant. - **options** (__type) - Optional - ### Response #### Success Response - **Assistant** (Promise) - The Assistant object if found. ``` -------------------------------- ### fromConnString Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint-redis/store/RedisStore/fromConnString Creates a new RedisStore instance by connecting to a Redis server using a provided connection string and optional configuration. This is a factory method for easy initialization. ```APIDOC ## fromConnString ### Description Initializes a RedisStore instance from a connection string. ### Method Signature `fromConnString(connString: string, config: StoreConfig): Promise` ### Parameters #### Path Parameters - **connString** (string) - Required - The connection string for the Redis server. - **config** (StoreConfig) - Optional - Configuration options for the store. ``` -------------------------------- ### Unknown Response Type Example Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/AgentTypeConfigLike/Response Illustrates the representation of an unknown response type. ```typescript Response: unknown ``` -------------------------------- ### RunsClient.create() Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/RunsClient Creates a new run. ```APIDOC ## RunsClient.create() ### Description Creates a new run. ### Method POST ### Endpoint /runs ### Parameters #### Request Body - **name** (string) - Optional - The name of the run. - **inputs** (object) - Optional - The inputs for the run. - **tags** (string[]) - Optional - Tags to associate with the run. ### Response #### Success Response (200) - **runId** (string) - The ID of the newly created run. - **status** (string) - The initial status of the run. ``` -------------------------------- ### get Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/ChannelProtocol/get Returns the current value of the channel. This method is available since version 0.0. ```APIDOC ## get ### Description Returns the current value of the channel. ### Method get() ### Parameters This method does not take any parameters. ### Response - **ValueType**: The current value of the channel. ``` -------------------------------- ### getChannels Source: https://reference.langchain.com/javascript/langchain-langgraph/index/StateSchema/getChannels Get the channel definitions for use with StateGraph. This converts the StateSchema fields into BaseChannel instances. ```APIDOC ## getChannels ### Description Get the channel definitions for use with StateGraph. This converts the StateSchema fields into BaseChannel instances. ### Method Signature ```typescript getChannels(): Record ``` ``` -------------------------------- ### withConfig Source: https://reference.langchain.com/javascript/langchain-langgraph/remote/RemoteGraph/withConfig Binds configuration parameters to a Runnable, returning a new Runnable with the specified configuration. ```APIDOC ## withConfig ### Description Binds configuration parameters to a Runnable, returning a new Runnable with the specified configuration. ### Method Signature ```typescript withConfig(config: RunnableConfig): RemoteGraph ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **config** (`RunnableConfig`) - Required - New configuration parameters to attach to the new runnable. ``` -------------------------------- ### get() Source: https://reference.langchain.com/javascript/langchain-langgraph/channels/EphemeralValue/get Retrieves the current value stored in the EphemeralValue channel. This method is part of the `@langchain/langgraph` library. ```APIDOC ## get() ### Description Retrieves the current value of the channel. ### Method `get()` ### Returns `Value` - The current value of the channel. ``` -------------------------------- ### create Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/RunsClient/create Initiates a run for a specified assistant and thread. This method requires the assistant ID and optionally accepts a thread ID and a payload for run creation. ```APIDOC ## create ### Description Creates a new run for a given assistant and thread. ### Method create ### Parameters #### Path Parameters - **threadId** (string | null) - Required - The ID of the thread. - **assistantId** (string) - Required - Assistant ID to use for this run. - **payload** (RunsCreatePayload) - Optional - Payload for creating a run. ### Response #### Success Response - **Run** (Promise) - The created run object. ``` -------------------------------- ### open() Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/ProtocolSseTransportAdapter/open Establishes a connection for SSE transports. This method returns a Promise that resolves when the connection is successfully opened. ```APIDOC ## open ### Description Establishes a connection for SSE transports. HTTP/SSE transports have no handshake — connections are made per-command and per-subscription. ### Method Signature `open(): Promise` ### Returns A Promise that resolves when the connection is successfully opened. ``` -------------------------------- ### Get Interrupt Value Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/ui/SubagentStreamInterface/interrupt Access the interrupt value from a stream. This is a convenience alias for `interrupts[0]`. ```typescript interrupt: Interrupt | undefined ``` -------------------------------- ### Configure Deep Agent Stream Options Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/UseDeepAgentStreamOptions Use this example to configure a deep agent stream with specific options. It includes setting the assistant ID, API URL, and deep agent-specific configurations like subagent tool names and message filtering. Error handling is also demonstrated. ```typescript const stream = useStream({ assistantId: "deep-agent", apiUrl: "http://localhost:2024", // DeepAgent-specific options subagentToolNames: ["task", "delegate"], filterSubagentMessages: true, onError: (error) => console.error(error), }); ``` -------------------------------- ### List all namespaces under a prefix Source: https://reference.langchain.com/javascript/langchain-langgraph-checkpoint/AsyncBatchedStore/listNamespaces Use this snippet to list all namespaces that start with a specific prefix and control the maximum depth of the search. Requires the store object to be initialized. ```javascript await store.listNamespaces({ prefix: ["documents"], maxDepth: 2 }); ``` -------------------------------- ### getScrapybaraClient Source: https://reference.langchain.com/javascript/langchain-langgraph-cua/utils/getScrapybaraClient Gets the Scrapybara client, using the API key from the graph's configuration object. ```APIDOC ## getScrapybaraClient ### Description Gets the Scrapybara client, using the API key from the graph's configuration object. ### Signature ```javascript getScrapybaraClient(apiKey: string): ScrapybaraClient ``` ### Parameters #### Path Parameters - **apiKey** (string) - Required - The API key for Scrapybara. ### Returns `ScrapybaraClient` The Scrapybara client. ``` -------------------------------- ### Initialize StateGraph with State Annotation and Options Source: https://reference.langchain.com/javascript/langchain-langgraph/index/StateGraph/constructor Initialize a StateGraph with a state annotation and specific input/output schemas defined in options. ```typescript const graph = new StateGraph(StateAnnotation, { input: InputSchema, output: OutputSchema, }); ``` -------------------------------- ### open Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/ProtocolSseTransportAdapter Opens the transport adapter. This method might be used to establish initial connections or prepare the adapter for use. ```APIDOC ## open() ### Description Opens the transport adapter. This method might be used to establish initial connections or prepare the adapter for use. ``` -------------------------------- ### Open a Thread Stream Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/client/ThreadsClient/stream Opens a thread stream using the assistantId. This is the basic usage for starting a stream. ```typescript const thread = client.threads.stream({ assistantId: "my-agent" }); ``` -------------------------------- ### Command Constructor Source: https://reference.langchain.com/javascript/langchain-langgraph/index/Command/constructor Initializes a new Command instance. This is used to define the parameters for a command, excluding the 'lg_name' which is handled internally. ```APIDOC ## constructor Command ### Description Initializes a new Command instance. This is used to define the parameters for a command, excluding the 'lg_name' which is handled internally. ### Signature ```javascript constructor = Record, Nodes extends string = string>(args: Omit, "lg_name">): Command ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **args** (Omit, "lg_name">) - Required - ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) * **Command** - The newly created Command instance. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### getSubgraphsSeenSet Source: https://reference.langchain.com/javascript/langchain-langgraph/web Gets the set of subgraphs that have been seen, useful for web-based graph visualization or management. This is a utility function. ```APIDOC ## getSubgraphsSeenSet ### Description Gets the set of subgraphs that have been seen. ### Method Not specified (likely a JavaScript function call) ### Endpoint Not applicable (SDK method) ### Parameters Not specified in the source text. ### Request Example Not specified in the source text. ### Response Not specified in the source text. ``` -------------------------------- ### Creating and Using an Agent with Typed Tool Calls Source: https://reference.langchain.com/javascript/langchain-langgraph-sdk/index/UseAgentStream Demonstrates how to create an agent with typed tools using `createAgent` and stream its output with `useStream` in a React component. Tool calls are automatically typed, allowing for safe access to arguments. ```typescript import { createAgent, tool } from "@langchain/langgraph"; import { useStream } from "@langchain/langgraph-sdk/react"; import { z } from "zod"; // Define tools with typed schemas const searchTool = tool( async ({ query }) => `Results for: ${query}`, { name: "search", schema: z.object({ query: z.string() }) } ); const calculatorTool = tool( async ({ expression }) => eval(expression).toString(), { name: "calculator", schema: z.object({ expression: z.string() }) } ); // Create the agent const agent = createAgent({ model: "gpt-4", tools: [searchTool, calculatorTool], }); // In React component: function Chat() { const stream = useStream({ assistantId: "my-agent", apiUrl: "http://localhost:2024", }); // Tool calls are typed! stream.toolCalls.forEach(tc => { if (tc.call.name === "search") { // tc.call.args is typed as { query: string } console.log("Searching for:", tc.call.args.query); } else if (tc.call.name === "calculator") { // tc.call.args is typed as { expression: string } console.log("Calculating:", tc.call.args.expression); } }); } ```