LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
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
WebChannelsPregelPrebuiltRemoteStream
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
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/langgraphremoteRemoteGraph
Class●Since v1.0

RemoteGraph

Copy
class RemoteGraph

Bases

Runnable<PregelInputType, PregelOutputType, PregelOptions<Nn, Cc, ContextType>>

Used in Docs

  • How to interact with a deployment using RemoteGraph

Constructors

Properties

Methods

Inherited fromRunnable(langchain_core)

Attributes

AInputTypeAOutputTypeAinput_schemaAoutput_schemaA
View source on GitHub
config_specs

Methods

Mget_nameMget_input_schemaMget_input_jsonschemaMget_output_schemaMget_output_jsonschemaMconfig_schemaMget_config_jsonschemaMget_graphMget_promptsMainvokeMbatch_as_completedMabatchMabatch_as_completedMastreamMastream_logMastream_eventsMstream_eventsMatransformMbindMwith_configMwith_listenersMwith_alistenersMwith_typesMwith_retryMmapMwith_fallbacksMas_tool

Example

Copy
import { RemoteGraph } from "@langchain/langgraph/remote";

// Can also pass a LangGraph SDK client instance directly
const remoteGraph = new RemoteGraph({
  graphId: process.env.LANGGRAPH_REMOTE_GRAPH_ID!,
  apiKey: process.env.LANGGRAPH_REMOTE_GRAPH_API_KEY,
  url: process.env.LANGGRAPH_REMOTE_GRAPH_API_URL,
});

const input = {
  messages: [
    {
      role: "human",
      content: "Hello world!",
    },
  ],
};

const config = {
  configurable: { thread_id: "threadId1" },
};

await remoteGraph.invoke(input, config);
constructor
constructor→ RemoteGraph<Nn, Cc, ContextType>
property
client: Client
property
config: RunnableConfig<Record<string, any>>
property
graphId: string
property
interruptAfter: "*" | keyof Nn[]
property
interruptBefore: "*" | keyof Nn[]
property
lc_kwargs: SerializedFields
property
lc_namespace: string[]

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

property
lc_runnable: boolean
property
lc_serializable: boolean
property
lg_is_pregel: boolean
property
name: string
property
streamResumable: boolean
property
lc_aliases
property
lc_attributes
property
lc_id
property
lc_secrets
property
lc_serializable_keys
method
_batchWithConfig
method
_callWithConfig
method
_checkpointToConfig→ RunnableConfig
method
_createStateSnapshot→ StateSnapshot
method
_getCheckpoint→ Checkpoint | undefined
method
_getConfig→ RunnableConfig
method
_getDrawableNodes→ Record<string, DrawableNode>
method
_getOptionsList
method
_rejectV3Unsupported
method
_sanitizeConfig→ __type
method
_separateRunnableConfigFromCallOptions
method
_streamEventsV3→ Promise<IterableReadableStream<Uint8Array<ArrayBufferLike>> | RemoteGraphRunStream<any, Record<string, unknown>>>
method
_streamIterator→ AsyncGenerator<any>

Default streaming implementation. Subclasses should override this method if they support streaming output.

method
_streamLog
method
_transformStreamWithConfig
method
assign
method
asTool
method
batch→ Promise<OperationResults<Op>>

Execute multiple operations in a single batch. This is more efficient than executing operations individually.

method
getGraphAsync→ Promise<Graph>

Returns a drawable representation of the computation graph.

method
getName
method
getState→ Promise<StateSnapshot>
method
getStateHistory→ AsyncIterableIterator<StateSnapshot>
method
getSubgraphsAsync→ AsyncGenerator<[string, PregelInterface<Nn, Cc, ContextType>]>
method
invoke→ Promise<any>
method
pick
method
pipe→ PregelNode<RunInput, Exclude<NewRunOutput, Error>>

Create a new runnable sequence that runs each individual runnable in series, piping the output of one runnable into another runnable or runnable-like.

method
stream→ Promise<IterableReadableStream<StreamOutputMap<TStreamMode, TSubgraphs, ExtractUpdateType<I, ExtractStateType<I, I>>, ExtractStateType<O, O>, "__start__" | N, NodeReturnType, InferWriterType<WriterType>, TEncoding>>>

Streams the execution of the graph, emitting state updates as they occur. This is the primary method for observing graph execution in real-time.

Stream modes:

  • "values": Emits complete state after each step
  • "updates": Emits only state changes after each step
  • "debug": Emits detailed debug information
  • "messages": Emits messages from within nodes
  • "custom": Emits custom events from within nodes
  • "checkpoints": Emits checkpoints from within nodes
  • "tasks": Emits tasks from within nodes
method
streamEvents→ Promise<IterableReadableStream<Uint8Array<ArrayBufferLike>>>

Generate a stream of events emitted by the internal steps of the runnable.

Use to create an iterator over StreamEvents that provide real-time information about the progress of the runnable, including StreamEvents from intermediate results.

A StreamEvent is a dictionary with the following schema:

  • event: string - Event names are of the format: on_[runnable_type]_(start|stream|end).
  • name: string - The name of the runnable that generated the event.
  • run_id: string - Randomly generated ID associated with the given execution of the runnable that emitted the event. A child runnable that gets invoked as part of the execution of a parent runnable is assigned its own unique ID.
  • tags: string[] - The tags of the runnable that generated the event.
  • metadata: Record<string, any> - The metadata of the runnable that generated the event.
  • data: Record<string, any>

Below is a table that illustrates some events that might be emitted by various chains. Metadata fields have been omitted from the table for brevity. Chain definitions have been included after the table.

ATTENTION This reference table is for the V2 version of the schema.

+----------------------+-----------------------------+------------------------------------------+
| event                | input                       | output/chunk                             |
+======================+=============================+==========================================+
| on_chat_model_start  | {"messages": BaseMessage[]} |                                          |
+----------------------+-----------------------------+------------------------------------------+
| on_chat_model_stream |                             | AIMessageChunk("hello")                  |
+----------------------+-----------------------------+------------------------------------------+
| on_chat_model_end    | {"messages": BaseMessage[]} | AIMessageChunk("hello world")            |
+----------------------+-----------------------------+------------------------------------------+
| on_llm_start         | {'input': 'hello'}          |                                          |
+----------------------+-----------------------------+------------------------------------------+
| on_llm_stream        |                             | 'Hello'                                  |
+----------------------+-----------------------------+------------------------------------------+
| on_llm_end           | 'Hello human!'              |                                          |
+----------------------+-----------------------------+------------------------------------------+
| on_chain_start       |                             |                                          |
+----------------------+-----------------------------+------------------------------------------+
| on_chain_stream      |                             | "hello world!"                           |
+----------------------+-----------------------------+------------------------------------------+
| on_chain_end         | [Document(...)]             | "hello world!, goodbye world!"           |
+----------------------+-----------------------------+------------------------------------------+
| on_tool_start        | {"x": 1, "y": "2"}          |                                          |
+----------------------+-----------------------------+------------------------------------------+
| on_tool_end          |                             | {"x": 1, "y": "2"}                       |
+----------------------+-----------------------------+------------------------------------------+
| on_retriever_start   | {"query": "hello"}          |                                          |
+----------------------+-----------------------------+------------------------------------------+
| on_retriever_end     | {"query": "hello"}          | [Document(...), ..]                      |
+----------------------+-----------------------------+------------------------------------------+
| on_prompt_start      | {"question": "hello"}       |                                          |
+----------------------+-----------------------------+------------------------------------------+
| on_prompt_end        | {"question": "hello"}       | ChatPromptValue(messages: BaseMessage[]) |
+----------------------+-----------------------------+------------------------------------------+

The "on_chain_*" events are the default for Runnables that don't fit one of the above categories.

In addition to the standard events above, users can also dispatch custom events.

Custom events will be only be surfaced with in the v2 version of the API!

A custom event has following format:

+-----------+------+------------------------------------------------------------+
| Attribute | Type | Description                                                |
+===========+======+============================================================+
| name      | str  | A user defined name for the event.                         |
+-----------+------+------------------------------------------------------------+
| data      | Any  | The data associated with the event. This can be anything.  |
+-----------+------+------------------------------------------------------------+

Here's an example:

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);
 }
}
method
streamLog
method
toJSON→ __type
method
toJSONNotImplemented
method
transform
method
updateState→ Promise<RunnableConfig<Record<string, any>>>
method
withConfig→ RemoteGraph<Nn, Cc, ContextType>

Bind config to a Runnable, returning a new Runnable.

method
withFallbacks
method
withListeners
method
withRetry
method
isRunnable
method
lc_name→ string

The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.

Implemented as a static method to support loading logic.

deprecatedmethod
getGraph→ Graph
deprecatedmethod
getSubgraphs→ Generator<[string, PregelInterface<Nn, Cc, ContextType>]>

The RemoteGraph class is a client implementation for calling remote APIs that implement the LangGraph Server API specification.

For example, the RemoteGraph class can be used to call APIs from deployments on LangSmith Deployment.

RemoteGraph behaves the same way as a StateGraph and can be used directly as a node in another StateGraph.