Skip to main content

PolicyClient

Opens a WebSocket to the server for model and reads its metadata. If the server offers a direct route to its GPU container, the client reconnects there and closes the proxied connection.
str
required
The model ID: "pi05", "pi0" or "groot". It fills {model} in WALLE_URL.
The constructor blocks until the server answers, with no timeout. On a server that is still loading its model, that can take a few minutes. Raises
  • KeyError if WALLE_URL is not set.
  • websockets.exceptions.InvalidStatus, InvalidURI or OSError if the server can’t be reached.

infer

Sends one observation and waits for the policy’s actions.
dict
required
Camera frames, state, prompt and any request options. The keys depend on the model. See Observations.
np.ndarray | dict[str, np.ndarray]
π0 and π0.5 return a float32 array of shape (action_horizon, action_dim), for example (50, 32). GR00T returns a dict of float32 arrays, one per action group, each of shape (1, action_horizon, k).
dict
If the server rejects the observation, infer returns {"type": "error", "message": str} and does not raise. The connection stays open, so you can fix the observation and call again. Check for this before executing actions. See Troubleshooting.
The returned arrays are read-only views of the received bytes. Call .copy() on one if you need to modify it in place.

reset

Starts the next observation fresh, as a new episode. It clears every session on this connection. Call it between episodes. See Episodes and reset.

get_server_metadata

Returns the settings the server sent on connect. It makes no network call.
int
Actions per chunk.
list[int]
[height, width] the server resizes frames to.
bool
Whether observations should carry a session_id.
int
π0 and π0.5 only. Width of each action.
int
π0 and π0.5 only. Maximum cameras per observation.
str
π0 and π0.5 only. "joint_position".
list[str]
GR00T only. Keys of the returned action dict.
str
GR00T only. The robot embodiment the server runs.
str
Present when the server offers a direct route. The client uses it automatically.

close

Closes the connection. Any call after close() raises websockets.exceptions.ConnectionClosed.

Environment variables

relay reads these from the environment, or from a .env file in the working directory or any parent directory. Variables already set in the environment take precedence.