RemoteGraph
is an interface that allows you to interact with your LangGraph Platform deployment as if it were a regular, locally-defined LangGraph graph (e.g. a CompiledGraph
). This guide shows you how you can initialize a RemoteGraph
and interact with it.
RemoteGraph
, you must always specify:
name
: the name of the graph you want to interact with. This is the same graph name you use in langgraph.json
configuration file for your deployment.api_key
: a valid LangSmith API key. Can be set as an environment variable (LANGSMITH_API_KEY
) or passed directly via the api_key
argument. The API key could also be provided via the client
/ sync_client
arguments, if LangGraphClient
/ SyncLangGraphClient
were initialized with api_key
argument.url
: URL of the deployment you want to interact with. If you pass url
argument, both sync and async clients will be created using the provided URL, headers (if provided) and default configuration values (e.g. timeout, etc).client
: a LangGraphClient
instance for interacting with the deployment asynchronously (e.g. using .astream()
, .ainvoke()
, .aget_state()
, .aupdate_state()
, etc.)sync_client
: a SyncLangGraphClient
instance for interacting with the deployment synchronously (e.g. using .stream()
, .invoke()
, .get_state()
, .update_state()
, etc.)client
or sync_client
as well as url
argument, they will take precedence over the url
argument. If none of the client
/ sync_client
/ url
arguments are provided, RemoteGraph
will raise a ValueError
at runtime.RemoteGraph
is a Runnable
that implements the same methods as CompiledGraph
, you can interact with it the same way you normally would with a compiled graph, i.e. by calling .invoke()
, .stream()
, .get_state()
, .update_state()
, etc (as well as their async counterparts).
url
or client
when initializing the RemoteGraph
.url
or sync_client
when initializing the RemoteGraph
..invoke()
or .stream()
invocations) are stateless - the checkpoints and the final state of the graph are not persisted. If you would like to persist the outputs of the graph run (for example, to enable human-in-the-loop features), you can create a thread and provide the thread ID via the config
argument, same as you would with a regular compiled graph:
checkpointer
with a graph that has a RemoteGraph
subgraph node, make sure to use UUIDs as thread IDs.RemoteGraph
behaves the same way as a regular CompiledGraph
, it can be also used as a subgraph in another graph. For example: