DreamClient
class DreamClientImportable as dream.DreamClient.
One client for embodiments, datasets, fine-tuning, models and inference, with the key bound once.
Construct it directly: dream.DreamClient(). The key comes from the argument or your credentials; where the Dream Labs services are is set by your credentials and cannot be changed from code. The embodiment, dataset, fine-tuning and model methods forward to the matching module function with this client’s key, and hold nothing open. policy(), set_observation(), get_action() and reset_episode() run a model.
policy() opens a session on the model, which close() releases; the class is also a context manager. One policy is held at a time: a second policy() replaces the first, closing it. set_observation() and get_action() may run on different threads at once, a control loop’s tick and a worker asking for the next chunk: a lock guards the window only while a tick goes in or the observation is copied out, never during a request, so set_observation() never waits for the model. Two get_action() at once are refused.
A context manager: use it in a with block. Entering: Returns the client itself; nothing is opened here. Leaving: Closes the client; the exception, if any, propagates unchanged.
Constructor
Section titled “Constructor”DreamClient(api_key: str | None = None)
Binds the key; nothing is sent and no session is opened.
A missing key is not an error here: the first call that needs it raises DreamConfigError.
Parameters
api_key(str | None, defaultNone): Your API key; the credentials’ (DREAM_API_KEY) when None.
Raises
DreamConfigError: The credentials file exists but cannot be read, or names a service that is not a URL.
DreamClient.add_embodiment
Section titled “DreamClient.add_embodiment”DreamClient.add_embodiment(name: str, config: dict[str, Any]) -> Embodiment
Records a robot body for the account; the config is checked here before it is sent.
The config is a dict:
state: each part of theobservation.statevector, by name, to its[start, end)span. The parts are your robot’s: their names, their widths and how many there are follow its arms. A body that records joints names them, e.g.{"right_arm": [0, 6], "right_gripper": [6, 7]}for one six-joint arm; one that records the end-effector pose names the EEF parts,{"right_eef_xyz": [0, 3], "right_eef_rot6": [3, 9], "right_grip": [9, 10]}, alone or beside the joints. The spans tile[0, width)with no gap or overlap, 128 wide at most.action: the same for theactionvector, which is what the model learns to answer: joint targets for the joint parts and end-effector targets for the EEF parts, as the dataset recorded them.video: each camera role to the dataset’s video key it reads, e.g.{"overhead": "observation.images.top"}; at least one.head_camera(optional when a role is namedoverhead): the role of the fixed head camera, the view the service labels the dataset’s tasks from; left out, theoverheadrole is used, and a body with neither is refused at registration.
Part names and roles are lowercase letters, digits and underscores, starting with a letter. No other key is taken; state_space and action_space, which older configs carried, are refused with a line saying so. A body that records its end-effector pose names the six EEF parts (right_eef_xyz, right_eef_rot6, right_grip and the left three) among its parts like any other; whether a fine-tune trains them is finetune()’s use_eef, not the config’s.
Parameters
name(str):[a-z0-9-]{1,64}, unique among the account’s embodiments.config(dict[str, Any]): The embodiment config above.
Returns
Embodiment: The new Embodiment, named <username>/<name>: pass its name to upload_dataset(), and its embodiment_config to validate_dataset().
Raises
DreamConfigError: The config is not valid (the message says what is wrong), or there is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden: ask Dream Labs support to set one).DreamServerError:conflictwhen a body of that name exists;invalid_requestfor a bad name; aretryableone (HTTP 5xx) may be made again after a short wait.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.get_embodiments
Section titled “DreamClient.get_embodiments”DreamClient.get_embodiments() -> list[Embodiment]
The account’s own embodiments, newest first.
Returns
list[Embodiment]: A list of Embodiment. An embodiment_config is what validate_dataset() takes; an id is what a fine-tune’s Model names as its embodiment.
Raises
DreamConfigError: There is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden: ask Dream Labs support to set one).DreamServerError: The data service refused the call; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.get_models
Section titled “DreamClient.get_models”DreamClient.get_models() -> list[Model]
The checkpoints the account may run: the public ones and its own fine-tunes.
Returns
list[Model]: A list of Model, public ones first. A model’s id is the checkpoint policy() takes. servable means it can be started, not that it is running: the first get_action() to a model that is not running is refused pool_warming while it starts.
Raises
DreamConfigError: There is no key.DreamAuthError: The key was refused.DreamServerError: The platform refused the call; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The platform could not be reached, or did not answer as the Dream API.
DreamClient.validate_dataset
Section titled “DreamClient.validate_dataset”DreamClient.validate_dataset(path: str, config: dict[str, Any]) -> Report
Runs the dataset checks on a local directory against an embodiment config; nothing is sent, no key needed.
These are the checks upload_dataset() runs before it sends anything, so a dataset that passes here passes there.
Parameters
path(str): The dataset directory: one LeRobot v2.1 dataset per subdirectory (<session>/meta/info.json,data/,videos/), or one such dataset itself;~is expanded, and hidden files are skipped.config(dict[str, Any]): The embodiment config of the body it was recorded on (anEmbodiment’sembodiment_config).
Returns
Report: The Report: ok and the counts, or ok=False and error, the one line to fix before uploading (a file that cannot be read is such a line too); fix it and check again.
Raises
DreamConfigError: The directory does not exist or cannot be listed, pyarrow is missing (the message says how to install the library), or the config is not valid.
DreamClient.upload_dataset
Section titled “DreamClient.upload_dataset”DreamClient.upload_dataset(path: str, name: str, embodiment: str) -> Dataset
Checks a local dataset against its embodiment, sends it to S3 as one zip and completes it.
The zip is written to the system’s temporary directory and removed before this returns or raises. Running the same call again after a DreamUploadError reuses the same dataset.
Parameters
path(str): The dataset directory: one LeRobot v2.1 dataset per subdirectory, or one such dataset itself.name(str):[a-z0-9-]{1,64}; free unless a dataset of that name is alreadyready_to_processor beyond.embodiment(str): The body it was recorded on, one of the account’s own, as<username>/<name>(anEmbodiment’sname).
Returns
Dataset: The Dataset as the service answered the completion, ready_to_process. Keep its id (get_datasets() finds it again by name) and poll get_dataset_status() until status is processed (then finetune() on its name) or failed (error says why).
Raises
DreamConfigError:nameis not[a-z0-9-]{1,64}(checked before anything is read or sent), the directory does not exist or cannot be listed, pyarrow or boto3 is missing (the message says how to install the library), or there is no key.DreamDatasetError: The local checks refused the dataset; nothing was sent. Import it fromdream.errors.DreamUploadError: The zip could not be written, the transfer did not finish, or the service did not find the zip at the declared size. Run the same call again. Import it fromdream.errors.DreamAuthError: The key was refused, or the account has no username yet (forbidden: ask Dream Labs support to set one).DreamServerError:conflictfor a name in use,not_foundfor an embodiment that is not the account’s; aretryableone (HTTP 5xx) may be made again after a short wait.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.get_dataset_status
Section titled “DreamClient.get_dataset_status”DreamClient.get_dataset_status(dataset_id: str) -> Dataset
A dataset’s status as the service holds it now; poll it after upload_dataset().
Parameters
dataset_id(str): The dataset’s id (ds_+ hex), as upload_dataset() answered it.
Returns
Dataset: The Dataset: status is ready_to_process, processing, processed or failed. Once it is processed, finetune() can queue a job on its name; when it is failed, error says why.
Raises
DreamConfigError: There is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden: ask Dream Labs support to set one).DreamServerError:not_foundwhen no dataset of that id is the account’s; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.get_datasets
Section titled “DreamClient.get_datasets”DreamClient.get_datasets() -> list[Dataset]
The account’s datasets, newest first, each with the status the service holds now.
Returns
list[Dataset]: A list of Dataset, a failed or deleted one included; its id is what get_dataset_status(), retry_dataset() and delete_dataset() take, its name what finetune() names.
Raises
DreamConfigError: There is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden: ask Dream Labs support to set one).DreamServerError: The data service refused the call; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.retry_dataset
Section titled “DreamClient.retry_dataset”DreamClient.retry_dataset(dataset_id: str) -> Dataset
Has a dataset whose processing failed processed again, from the zip already uploaded.
Parameters
dataset_id(str): The dataset’s id (ds_+ hex), as upload_dataset() answered it.
Returns
Dataset: The Dataset, ready_to_process; poll get_dataset_status() as after an upload. A retry that raced another call on the same dataset (a second retry, an upload under its name) answers it as that call left it.
Raises
DreamConfigError: There is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError:not_foundwhen no dataset of that id is the account’s, or the deployment offers no retries;conflictwhen it is notfailed, or its upload never finished (upload it again under the same name instead).DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.delete_dataset
Section titled “DreamClient.delete_dataset”DreamClient.delete_dataset(dataset_id: str, *, confirm: bool = True) -> Dataset | None
Deletes a dataset by its id after asking you to confirm; refused while a job on it is queued or running.
Parameters
dataset_id(str): The dataset’s id (ds_+ hex), as upload_dataset() answered it.confirm(bool, defaultTrue, keyword-only): Ask on the terminal first; False skips the question.
Returns
Dataset | None: The Dataset, deleted; None when you did not confirm.
Raises
DreamConfigError: There is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden).DreamServerError:not_foundwhen no dataset has that id.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.finetune
Section titled “DreamClient.finetune”DreamClient.finetune( dataset: str, suffix: str, *, purpose: str | None = None, steps: int | None = None, learning_rate: float | None = None, batch_size: int | None = None, use_eef: bool = False, lr_schedule: str | None = None, resume_from: str | None = None, base_share: float | None = None, ) -> dict[str, Any]
Queues a fine-tuning job on one of the account’s processed datasets.
A knob left as None is not sent, and the service fills in its default; the job’s hyperparameters says what it trains with. A knob out of range is refused with invalid_request, naming it. With use_eef, the dataset’s embodiment is fetched and checked here first (dream.fine_tuning.check_eef), so a body that cannot train the end-effector pose is refused before anything is queued.
Parameters
dataset(str): The dataset’s<username>/<name>(aDataset’sname), one of the account’s own andprocessed.suffix(str):[a-z0-9-]{1,40}: the tail of the checkpoint iddream-1-ft:<uid8>-<suffix>; free among the account’s models and active jobs.purpose(str | None, defaultNone, keyword-only):"embodiment"(a new robot body: half of each batch is Dream Labs data by default; bimanual robots with parallel grippers are the ones officially supported, and an out-of-distribution body should train10000steps) or"task"(automate a task: the account’s data alone by default; fewer than10000steps will not give the best result). None takes"embodiment", or"task"whenstepsis over10000.steps(int | None, defaultNone, keyword-only): The training steps, any multiple of100:500to10000for an embodiment, default500;5000to30000for a task, default10000. None takes the purpose’s default. The price grows with the steps, and so does the time.learning_rate(float | None, defaultNone, keyword-only): The learning rate, 1e-6 to 1e-4; None takes the service’s default of 1e-5.batch_size(int | None, defaultNone, keyword-only): Leave it as None: the service sets it.use_eef(bool, defaultFalse, keyword-only): Whether the job trains the end-effector pose beside the joints. The dataset’s embodiment must then carry the six EEF parts,right_eef_xyz(3 wide),right_eef_rot6(6),right_grip(1) and the same three forleft, in bothstateandaction. False, the default, trains every part as joints. A body whoseactioncarriesright_eef_rot6orleft_eef_rot6trains only with it; without it the service refuses the job withinvalid_request. So does one whoseactioncarriesright_eef_xyzorleft_eef_xyzwithout that side’s_eef_xyz(3 wide) and_eef_rot6(6 wide) instate. The pose follows the base model’s convention, per arm:<side>_eef_xyzis the tool centre point in metres (on YAM 0.1347 m past the wrist flange along the last link’s z axis),<side>_eef_rot6the last link’s orientation as the first two columns of its rotation matrix,[R00, R10, R20, R01, R11, R21], both in that arm’s own base frame, and<side>_gripthe gripper opening, 0 closed to 1 open. A pose recorded another way passes every check and trains a mismatched model.lr_schedule(str | None, defaultNone, keyword-only): The learning-rate schedule,"constant"or"cosine"; None takes the service’s default,"constant". Both warm up first;"cosine"then decays the rate to 0 by the last step. Cosine decay works best for specialization (a fine-tune on a single task). You may not get high reliability on specialist tasks yet.resume_from(str | None, defaultNone, keyword-only): The id of one of the account’s fine-tuned models (dream-1-ft:...) to keep training: the job picks up where its training ended, optimizer and learning-rate schedule included, forstepsnew steps, and is charged for those alone. The model must be the account’s, trained after resuming was added and finished to its last step; the dataset must be on the same robot, andlearning_rate,batch_sizeanduse_eefmust stay the model’s, at the"constant"schedule. None, the default, trains a new model from the base.base_share(float | None, defaultNone, keyword-only): The share of each training batch drawn from Dream-1’s own general training data,0.5or0.0; None takes the service’s default of0.5. Half keeps more of what the model already does in general;0.0trains on the account’s sessions alone, which fits them more closely but can lose general skill. The site’s Fine-tune form offers the same choice as Training data: “Mix in Dream Labs data” is0.5, “Train on my data only” is0.0. A job that continues a model keeps that model’s value.
Returns
dict[str, Any]: The job dict, status queued, with the keys id (ftj_ + hex), dataset, embodiment, base_model, suffix, fine_tuned_model (None until the model is published), status, hyperparameters (the training settings as filled in), queue_position, created_at, finished_at and error (get_finetuning_status() says what each holds). Keep job["id"] and poll get_finetuning_status() with it.
Raises
DreamConfigError: There is no key, a knob is not a plain number, oruse_eefis asked of a dataset whose embodiment lacks an EEF part or has one at another width (the message names the part and its side).DreamAuthError: The key was refused, or the account has no username yet (forbidden: ask Dream Labs support to set one).DreamServerError:not_foundfor a dataset that is not the account’s;conflictfor one that is notprocessed, a suffix in use, or the account at its limit of active jobs;invalid_requestfor a suffix or a knob out of range, naming it, aresume_fromthe job cannot continue, saying why, or for a dataset whose embodiment’s action carries an end-effector rotation, or a position without its state pose, withoutuse_eef; aretryableone (HTTP 5xx) may be made again after a short wait.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.get_finetuning_status
Section titled “DreamClient.get_finetuning_status”DreamClient.get_finetuning_status(job_id: str) -> dict[str, Any]
A fine-tuning job as the service holds it now; poll it after finetune().
The job dict’s keys:
id:ftj_+ hex.dataset,embodiment: the dataset it trains on and that dataset’s embodiment, each<username>/<name>.base_model: the id of the checkpoint it starts from.suffix: the suffix it was created with.fine_tuned_model: the new checkpoint’s id,dream-1-ft:<uid8>-<suffix>, once the job has succeeded and the checkpoint is published; None before.status:queued(waiting for a training slot),running,succeeded,failedorcancelled.hyperparameters: the training settings, as the service filled them in.queue_position: 1 for the next job to start, whilequeued; None otherwise.created_at,finished_at: ISO 8601 times in UTC;finished_atis None until the job ends.error: one line saying the training did not finish, whenfailed; None otherwise.
Poll until fine_tuned_model is set, not until succeeded alone: the checkpoint is published in the same pass that marks the job succeeded, or a little later. A failed or cancelled job never gets one, so stop polling there.
Parameters
job_id(str): The job’s id (ftj_+ hex), as finetune() answered it.
Returns
dict[str, Any]: The job dict above. Once fine_tuned_model is set, client.policy({"checkpoint": job["fine_tuned_model"]}) runs the model.
Raises
DreamConfigError: There is no key.DreamAuthError: The key was refused, or the account has no username yet (forbidden: ask Dream Labs support to set one).DreamServerError:not_foundfor a job that is not the account’s; aretryableone (HTTP 5xx, already retried by the client) may be made again after a short wait.DreamProtocolError: The data service could not be reached, or did not answer as the Dream API.
DreamClient.policy
Section titled “DreamClient.policy”DreamClient.policy(config: dict[str, Any]) -> None
Chooses the model and opens an empty frame window; nothing is sent until the first get_action().
The checkpoint is a model’s id: a Model’s id from get_models(), or a fine-tuning job’s fine_tuned_model. Opening a second policy closes the first, which ends its session and empties its window.
For a fine-tune of a custom body (the account’s own, or a shared or public one whose body another account registered), when config names no embodiment and strict is on (the default), the embodiment config of the body it was trained on is loaded here, from get_models(), and kept for the session: every get_action() then checks the observation before anything is sent, and the model’s reply before it is returned, and a body with parts is converted to the slots its model trained on and back. strict: False with no embodiment loads nothing, so it skips both: calls are sent unchecked and unconverted, in the slot names the model trained on, never a robot’s own parts. A model of a builtin body (a Dream-1 base model) has no config to load, so its calls are not checked. With strict on, a lookup that fails raises (DreamProtocolError; call policy() again), and so do a checkpoint get_models() does not name and a listed config this library cannot read: nothing runs unchecked by accident. What one of your fine-tunes was trained on, each camera’s frame sizes and its tasks, is read here once per checkpoint (dream.trained_inputs.fetch()), for get_action()’s lines; a lookup that fails prints one line and never refuses.
Parameters
config(dict[str, Any]): The session config, a dict (yours is not changed):checkpoint(required); optionallyembodimentfor the checks (the embodiment config the body was registered with, the dict add_embodiment() took, or a shape spec; loaded for a fine-tune of a custom body when left out);obs_window(int, at least 1, default 9: frames kept per frame key) andobs_fps(a positive, finite number, default 5: frames kept per second of set_observation()’s timestamps);timeout_ms(milliseconds, default 15000) andstrict(default True); the pacing keysexecution_horizon(rows, default 30),action_hz(rows per second, default 20) andsync_above_ms(default 700), read by refill_due();kinematics;robot, the robot the model runs on as a model trained on YAM arms reads it,"yam"(a YAM) or"other_embodiment"(any other arm), which every get_action() sends as the observation’sembodiment(never put that key in your observation): on"other_embodiment"the serve may ignore the arm’s state, and the model answers no joints, only each hand’s pose, composed on the hand pose the observation carries (per_key‘saction.right_armandaction.left_armare None); left out, it is"other_embodiment"whenikruns a model trained on YAM arms on an arm that is not a YAM, and nothing is sent otherwise; set it to"other_embodiment"to ask the same with IK of your own; andik, which runs a model that answers hand poses on an arm that is not a YAM:{"arm": ..., "head": "eef"}, the arm being"metal","makers"or the path of an arm file, a JSON object with every one of these keys:urdf(your arm’s URDF, a path relative to the arm file),base(the link the hand’s pose is measured from, oriented x forward, y to the arm’s left, z up),flange(the link the gripper is mounted on),tcp([x, y, z], metres in the flange link’s frame: the point between the closed fingertips),approach([x, y, z]in the flange link’s frame: the way the fingers point),jaw([x, y, z]in the flange link’s frame: the line the fingers close along, pointing to the arm’s left when the hand points straight forward) andrest(the arm’s joints in a working pose, in radians and inside the joint limits: the pose the solve leans toward). The user measures and confirmstcp,approachandjawon the real gripper (dreamcli tcpwrites the arm file); an agent writing this config never picks or estimates them. Both arms run the same arm file, each from its own base; the arm’s joints are the moving joints frombasetoflange, in that order. The client then adds each hand’s pose to the observation, fromstate.<side>_arm, and returns the reply’s poses asq_r_chunkandq_l_chunk: your arm’s joints, then the grip (the docs’ “On another arm”). policy() warns once, never refusing (oneUserWarningline), when the arm file’s tool point is not one a person set on the real gripper withdreamcli tcp: no record of it, a skipped one, one edited since, ortcpat the flange itself. Every key butcheckpoint,embodimentandrobotis consumed here and never sent.
Raises
DreamConfigError:checkpointis missing, a key has the wrong type or range, the config carries a key the client does not take (host,portandschemeamong them: where the model is comes from your credentials), theembodimentgiven is not valid,robotis not"yam"or"other_embodiment",ikcannot be served (dream.client_ik; its headjointwithrobot"other_embodiment"neither); acheckpointget_models() does not name, a fine-tune of a robot registered with parts the platform lists only to the account that registered it (Model.parts_withheld), or one whose listed config this library cannot read, withstricton and noembodiment(the message says to pass it).obs_windowandobs_fpsare checked before anything else, so a policy already open stays open when they are wrong.DreamProtocolError: Withstricton and noembodiment, the model lookup (get_models()) failed, so nothing is checked or converted and nothing opens; call policy() again. A policy already open stays open.
DreamClient.set_observation
Section titled “DreamClient.set_observation”DreamClient.set_observation( frames: Mapping[str, str], observation: Mapping[str, Any], *, timestamp: float | None = None, ) -> None
Hands the client one camera tick: its frames go into the window when due, its observation replaces the last.
Call it on every camera tick, at whatever rate the cameras run. The first tick of an episode is kept, then one every 1 / obs_fps seconds of timestamp, the tick nearest each due time; each frame key keeps its last obs_window frames. A tick whose frames are not kept still replaces the observation, so get_action() always sends the newest state. It costs a few operations per frame key, never waits for a get_action() running on another thread, and never waits on the network. The client keeps a copy of the mapping as it is at the call.
Parameters
frames(Mapping[str, str]): Per window key, one frame. The key is the observation key the checkpoint reads the window under,video.<role>: one per role of a fine-tuned model’s embodimentvideo;video.overhead,video.wrist_landvideo.wrist_rfordreamlabs/dream-1-betaon a YAM (the deprecatedimage_window.<role>are still accepted). The frame is one base64 JPEGstr, resized and encoded by you; the client never decodes it. The same keys on every call of an episode.observation(Mapping[str, Any]): Every other key the checkpoint reads: onestate.<part>per part of a fine-tuned model’s embodimentstate;state.right_arm,state.right_gripper,state.left_armandstate.left_gripperfordreamlabs/dream-1-betaon a YAM, whose hand posesikadds (or, deprecated, the YAM station’sstate.arm_r.*andstate.arm_l.*); andprompt; neverembodiment, which the client sends from policy()’srobot(get_action() refuses it). It replaces the last call’s whole, nothing merged. The client keeps a copy of the mapping, so changing yours later changes nothing sent; the values (a numpy array) are not copied. Values are what JSON carries (numbers, strings, lists, numpy arrays), never bytes.timestamp(float | None, defaultNone, keyword-only): When the frames were captured, seconds on a monotonic clock;time.monotonic()at the call when None. Never earlier than the last call’s within an episode.
Raises
DreamConfigError: No policy is open: call policy({“checkpoint”: …}) first.DreamObservationError:framesis not a non-empty mapping of non-emptystrkeys to one non-emptystrframe each (bytes: send base64),observationis not a mapping or carries a frame key, the frame keys are not those of the episode’s earlier calls, ortimestampis not a finite number or is earlier than the last call’s. The message names the key, and the window is unchanged.
DreamClient.get_action
Section titled “DreamClient.get_action”DreamClient.get_action(*, commanded: Mapping[str, Any] | None = None) -> dict[str, Any]
Sends the window and the latest observation to the model and returns its action chunk.
The observation sent is the last set_observation()’s, plus, under each frame key, the frames kept so far in the episode, oldest first: obs_window of them once the window is full, fewer at the start of an episode, never none. The first call of an episode opens a session on the model, and later calls continue it. The first call to a model that is not running yet is refused DA-2000 pool_warming while the model starts: wait retry_after_s and call again. When the round trips stay slow (a median of 1000 ms or more over the last five), it issues one dream.DreamSlowNetworkWarning, a Python warning that is never raised, and returns the action as usual. One call at a time: run it on a thread of its own and keep calling set_observation() from your camera loop meanwhile. A policy’s first call prints one UserWarning line, never refusing, until a person records on this computer that they checked what the model sees for these cameras and this robot config (input_check; the line names the command). On one of your fine-tunes, an episode’s first call also prints one UserWarning line, once a policy, for each camera whose aspect and for a prompt that differ from what it was trained on, never refusing (trained_inputs); DebugView shows them too.
Parameters
commanded(Mapping[str, Any] | None, defaultNone, keyword-only): Per chunk key (q_r_chunk,q_l_chunk), the joints your loop last commanded that arm before the observation, or None; never sent. With them each chunk takes over at the row after those joints, where the loop is, instead of the row nearest the measured joints, which a real arm trails by a few rows.
Returns
dict[str, Any]: The action dict. A fine-tuned model’s actions are under per_key: one action.<part> per part of its config’s action, as rows, one per step (48 for Dream-1). A YAM body’s are q_r_chunk and q_l_chunk, [H, joints + 1] (the arm’s joint targets, then the gripper), already blended into the previous chunk so the control loop meets no step where one chunk replaces the last. Any other key the model adds is passed through.
Raises
DreamConfigError: No policy is open: call policy({“checkpoint”: …}) first. Also: the host is not a valid host name, or the API key holds a character an HTTP header cannot carry.DreamObservationError: Before anything is sent: no set_observation() since the episode started, the observation carriesembodiment(set policy()’srobotinstead), the observation built does not match the embodiment config (checked for a fine-tune of a custom body, or theembodimentgiven), or a value cannot be sent as JSON. The message names the key.DreamActionError: The model’s reply is not a usable action: it does not match the embodiment config, or it carries no action dict or a chunk that is not rows of numbers. Nothing is returned.DreamTimeout: No answer withintimeout_ms(15000 ms by default); calling again is safe.DreamProtocolError: The model could not be reached, or what answered is not the Dream API; check the URL and the network, then call again.DreamAuthError: The key was refused (DA-1000): missing, unknown, revoked, or the checkpoint is not available to run on this account. Never retryable.DreamBadRequest: The model refused the request as malformed (DA-4000):reasonisunknown_checkpoint(use an id get_models() lists),too_large(send smaller frames) ormalformed. Never retryable.DreamSessionExpired: The model replaced the session mid-episode (DA-0001with a reason other thannew). The new session is already in use and the action is not returned: call again to continue on it, or reset_episode() to start the episode over.DreamServerError: Any other refusal, withcode,reason,retryableandretry_after_s:DA-2000(pool_warming: the model is starting;rate_limited: the calls came too fast;pool_full,queue_timeout: it is at max capacity;max_serves: it is at max capacity and no more copies of it may start, soretryableis False, though a gateway that sets itsretry_after_smay have a seat free after that wait),DA-5000(the model failed the call) orDA-6000(a fault on the Dream Labs side;cannot_scale: the model cannot be started, the message says why). Whenretryableis True, waitretry_after_sseconds (a moment when it is None) and call again.DreamError: The client is closed, or another get_action() is running on it.
DreamClient.on_round_trip
Section titled “DreamClient.on_round_trip”DreamClient.on_round_trip(fn: Callable[[RoundTrip], object]) -> None
Calls fn after every get_action() with what the model was sent and what came back.
fn gets one RoundTrip per get_action() that built its observation, a refused or failed call included (its error is set and its action is None). It runs on the thread that called get_action(), after the request and before get_action() returns or raises, so keep it short; an exception it raises comes out of get_action(). Nothing is copied or sent for it. DebugView is one such fn: a page on this computer of the frames the model saw, the state, the chunk, the timing and any refusal.
Parameters
fn(Callable[[RoundTrip], object]): The callable, called with the RoundTrip; what it returns is ignored. Registered for the life of this client, every policy included.
DreamClient.reset_episode
Section titled “DreamClient.reset_episode”DreamClient.reset_episode() -> None
Ends the episode: ends the session on the model, then empties the window.
The next set_observation() is the first tick of a new episode, and the next get_action() starts a new session. Call it between episodes, when the robot is reset.
Raises
DreamConfigError: No policy is open: call policy({“checkpoint”: …}) first.DreamError: A get_action() is running on another thread, or the client is closed; the session and the window are both left as they were, so calling it again once the get_action() returns is safe.
DreamClient.wait_for_ik
Section titled “DreamClient.wait_for_ik”DreamClient.wait_for_ik(timeout_s: float) -> bool
Waits until the IK policy() built (its ik key) has compiled every solve it runs.
With head eef the client solves with tick at once and compiles traj on a thread of its own: seconds of CPU, up to about 20 on one slow core. A robot program calls this before it powers arms those seconds would starve, such as a Metal arm’s grippers on their 500 ms CAN timeout.
Parameters
timeout_s(float): Seconds to wait at most.
Returns
bool: True once compiled, and at once without ik or with nothing left to compile; False after timeout_s.
Raises
DreamConfigError: No policy is open: call policy({“checkpoint”: …}) first.
DreamClient.refill_due
Section titled “DreamClient.refill_due”DreamClient.refill_due(executed: int, remaining: int) -> bool
Whether your loop should call get_action() now, by the pacing of the open policy (dream.pacing).
It measures every round trip and paces async (the request goes out so its reply lands as execution_horizon rows have run) or sync (only once the chunk is used up, when a call is slower than sync_above_ms).
Parameters
executed(int): Rows of the current chunk your loop has run since the chunk took over.remaining(int): Rows of it still to run.
Returns
bool: True when a get_action() should start, given none is running.
Raises
DreamConfigError: No policy is open: call policy({“checkpoint”: …}) first.
DreamClient.execution_horizon
Section titled “DreamClient.execution_horizon”DreamClient.execution_horizon: intA read-only property.
Rows of each chunk your loop runs before the next one takes over, the open policy’s execution_horizon.
Raises
DreamConfigError: No policy is open.
DreamClient.action_hz
Section titled “DreamClient.action_hz”DreamClient.action_hz: floatA read-only property.
Rows per second your loop runs, the open policy’s action_hz.
Raises
DreamConfigError: No policy is open.
DreamClient.mode
Section titled “DreamClient.mode”DreamClient.mode: strA read-only property.
How the open policy paces get_action() now: async or sync (dream.pacing).
Raises
DreamConfigError: No policy is open.
DreamClient.last_timing
Section titled “DreamClient.last_timing”DreamClient.last_timing: dict[str, Any] | None
A read-only property.
Where the last get_action()’s time went (round trip, bytes, the model’s timing), or None before the first.
None when no policy is open.
DreamClient.checkpoint
Section titled “DreamClient.checkpoint”DreamClient.checkpoint: str | None
A read-only property.
The model the open policy runs, the checkpoint policy() was given; None when no policy is open.
DreamClient.session_id
Section titled “DreamClient.session_id”DreamClient.session_id: str | None
A read-only property.
The session the model answers the episode under, once get_action() opened it; else None.
DreamClient.close
Section titled “DreamClient.close”DreamClient.close() -> None
Empties the window and releases the open inference session, if any; calling it again does nothing.
Leaving a with block calls it. The embodiment, dataset, fine-tuning and model calls hold nothing open.