🌍 Global Mirror — Visit original CN site →
ClassSince v0.2

RemoteGraph

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 Graph and can be used directly as a node in another Graph.

RemoteGraph(
  self,
  assistant_id: str,
  ,
  *,
  url: str | None = None,
  api_key: str | None = None,
  headers: dict[str, str] | None = None,
  client: LangGraphClient | None = None,
  sync_client: SyncLangGraphClient | None = None,
  config: RunnableConfig | None = None,
  name: str | None = None,
  distributed_tracing: bool = False
)

Parameters

NameTypeDescription
assistant_id*str

The assistant ID or graph name of the remote graph to use.

urlstr | None
Default:None

The URL of the remote API.

api_keystr | None
Default:None

The API key to use for authentication. If not provided, it will be read from the environment (LANGGRAPH_API_KEY, LANGSMITH_API_KEY, or LANGCHAIN_API_KEY).

headersdict[str, str] | None
Default:None

Additional headers to include in the requests.

clientLangGraphClient | None
Default:None

A LangGraphClient instance to use instead of creating a default client.

sync_clientSyncLangGraphClient | None
Default:None

A SyncLangGraphClient instance to use instead of creating a default client.

configRunnableConfig | None
Default:None

An optional RunnableConfig instance with additional configuration.

namestr | None
Default:None

Human-readable name to attach to the RemoteGraph instance. This is useful for adding RemoteGraph as a subgraph via graph.add_node(remote_graph). If not provided, defaults to the assistant ID.

distributed_tracingbool
Default:False

Whether to enable sending LangSmith distributed tracing headers.

Constructors

constructor
__init__
NameType
assistant_idstr
urlstr | None
api_keystr | None
headersdict[str, str] | None
clientLangGraphClient | None
sync_clientSyncLangGraphClient | None
configRunnableConfig | None
namestr | None
distributed_tracingbool

Methods

method
copy
method
with_config
method
get_graph

Get graph by graph name.

This method calls GET /assistants/{assistant_id}/graph.

method
aget_graph

Get graph by graph name.

This method calls GET /assistants/{assistant_id}/graph.

method
get_state

Get the state of a thread.

This method calls POST /threads/{thread_id}/state/checkpoint if a checkpoint is specified in the config or GET /threads/{thread_id}/state if no checkpoint is specified.

method
aget_state

Get the state of a thread.

This method calls POST /threads/{thread_id}/state/checkpoint if a checkpoint is specified in the config or GET /threads/{thread_id}/state if no checkpoint is specified.

method
get_state_history

Get the state history of a thread.

This method calls POST /threads/{thread_id}/history.

method
aget_state_history

Get the state history of a thread.

This method calls POST /threads/{thread_id}/history.

method
bulk_update_state
method
abulk_update_state
method
update_state

Update the state of a thread.

This method calls POST /threads/{thread_id}/state.

method
aupdate_state

Update the state of a thread.

This method calls POST /threads/{thread_id}/state.

method
stream

Create a run and stream the results.

This method calls POST /threads/{thread_id}/runs/stream if a thread_id is speciffed in the configurable field of the config or POST /runs/stream otherwise.

method
astream

Create a run and stream the results.

This method calls POST /threads/{thread_id}/runs/stream if a thread_id is speciffed in the configurable field of the config or POST /runs/stream otherwise.

method
astream_events
method
invoke

Create a run, wait until it finishes and return the final state.

method
ainvoke

Create a run, wait until it finishes and return the final state.