Skip to main content
The public API of the dreamscale package, version 0.1.0a373. For a walkthrough, start at Python SDK.

What you need

  • Python 3.11 or newer, and the package: uv add dreamscale.
  • An account: sign in once with uv run dreamscale login, or set DREAMSCALE_API_KEY.

Overview

dreamscale.connect()

Connect to a model and return a Policy. It returns once a server is ready. If every server is busy, it waits in a queue and shows your position.
dreamscale.connect
Raises AuthError, CreditsError or NoCapacityError when it can’t connect.
It prints 30 x 6.

dreamscale.aconnect()

The same as connect(), awaited, for async code. It takes the same parameters and returns an AsyncPolicy.
dreamscale.aconnect

Policy

What connect() returns: one connection to a model. If the connection drops, the next call reconnects. After a minute with nothing in flight, it frees the server, and the next call reconnects. It closes when your program exits. Use it as a context manager to close it when the block ends:

Policy.predict()

Send one observation and get back one action chunk: the model’s next actions. It doesn’t move the robot.
dreamscale.Policy.predict
Raises ObservationError before sending if the observation, its history or the committed actions don’t match the model, and Error with code history_required if you leave out history the model can’t run without.

Running chunks on your own clock

predict() returns one chunk and leaves running it to you. (next_action() does it for you: buffering, early requests, blending.) What the server does. With committed_actions and policy.contract.rtc "train_time", the server estimates how many of them your robot will execute before the new chunk reaches this computer. It counts from capture_time_ns through upload, queueing, inference and the trip back, measured on your session’s recent requests. It pins that many (prefix_rows: at most policy.contract.max_prefix_rows, and at most the rows you sent), returns them exactly as you sent them, and generates the rest to follow on. On a deployment with "inference_time", it guides the start of the new chunk toward them over the same count instead: close to what you sent, not exact. Without committed_actions, each chunk starts fresh. What you do.
  • Rows and time. Row 0 is the first action to execute after chunk.capture_time_ns; row i follows i / policy.contract.action_hz seconds later. Times are this computer’s time.time_ns(): convert them if your robot stamps frames on another clock.
  • Request early. Send the next request while the current chunk still has at least ceil(latency × action_hz) + 1 actions left, where latency is capture to receipt, measured on your own chunks.
  • Commit what will run. Pass the actions your robot will execute after the new observation, after any limits your controller applies. Rows past what the server can pin are ignored. After a reconnect, keep passing them.
  • Switch. When the chunk arrives, switch at the row due now: floor((now − capture_time_ns) × action_hz).
Checking it works. Compare the row you switch at with prefix_rows:
  • At or below prefix_rows: smooth. The pinned rows match what was playing.
  • Above prefix_rows: the chunk arrived later than estimated, and the robot jumps at the switch. The estimate ends when the chunk reaches this computer, so a delay before your controller switches isn’t in it. Switch sooner after arrival, or request earlier.
  • Equal to the rows you sent: you capped it. Send more.
  • Equal to max_prefix_rows on most chunks: latency takes most of each chunk, leaving few new actions. Request earlier, or cut latency.
  • 0: you sent no rows, because the chunk ran out first. Request earlier.
Handing over to another deployment. Request its first chunk the same way, early, while the current chunk still has the latency’s worth of actions left, then switch at the row due now:

History the model reads

Some models read the ticks before the observation as well, FLUX.3 Action among them. policy.contract.past_observations and policy.contract.action_history say how many to pass; both are 0 for models that don’t.
  • Keep the last ticks. On every control tick, at action_hz, keep the observation and the action you sent. Pass the most recent as past_observations and action_history; extra ones are ignored.
  • Episode start. Pass [] or fewer: the SDK pads them as the model was trained, and chunk.history_padded says how many ticks it filled in. Once the episode is a few ticks in, it should be 0.
  • No gaps. With capture times, the entries must be one control tick apart, up to the observation. A gap raises ObservationError before sending.
Praxis-1 reads every step your robot executed since the episode began:
  • Run every row. A chunk holds 21 rows on an episode’s first call and 24 after. Run all of them.
  • Pass the executed steps. As past_observations, pass the observation each action was executed from since your previous predict(), oldest first. The first is the observation you passed to that call.
  • Leave out the waits. Ticks where the arm held still while you waited for a chunk aren’t steps, so the no-gaps rule doesn’t apply here.
  • Start an episode with []. After an episode’s first call, a call without past_observations raises Error with code episode_steps_required, so an episode never starts over by accident.
The robot will move. Enforce joint, speed and workspace limits locally, and keep a physical e-stop within reach. Cloud inference does not replace your robot’s safety controller.

Policy.next_action()

Get one action to execute now. Call it once per control tick: it returns on the model’s clock, within one tick. In async mode it asks for the next chunk while rows remain and joins chunks so motion stays smooth; in sync mode (Praxis-1’s default, see connect(mode=)) it runs each chunk to its end, then asks. While no model action is ready (the first chunk, or a reconnect), an arm gets its measured position back so it holds still; Praxis-1 holds its last command between chunks.
dreamscale.Policy.next_action
Returns one action: absolute joint targets for a robot arm, in the same order and units as its observation (see Models). With real-time chunking (policy.contract.rtc is "train_time"), each request carries the actions still to execute, so chunks join without a jump; there is nothing to pass.

Policy.prefetch()

Request a policy’s first chunk ahead of handing the robot over to it, so its first next_action() doesn’t hold. Call it about one round trip before the switch, with the same instruction; it returns without waiting for the chunk.
dreamscale.Policy.prefetch

Policy.close()

Close the session now. Optional: an idle policy frees its server after a minute (on a deployment kept warm, after its keep-warm; with always, never), and every policy closes when your program exits.
dreamscale.Policy.close

Policy.contract

What the connected model returns and accepts. Read-only.

AsyncPolicy

What aconnect() returns. It has the same properties as Policy, and the same methods, awaited: await policy.predict(...), await policy.next_action(...) and await policy.close(). Use async with policy: to close it when the block ends.
dreamscale.AsyncPolicy.predict
dreamscale.AsyncPolicy.next_action

Action chunk

What predict() returns.

Observation helpers

Each robot type has one helper, shared by every model on that robot. It checks the values before anything is sent and raises ObservationError naming any wrong field. Frames are H×W×3 uint8 RGB at any size: the SDK resizes them for the model.

dreamscale.so101.observation()

dreamscale.so101.observation

dreamscale.yam.observation()

dreamscale.yam.observation

dreamscale.libero.observation()

dreamscale.libero.observation

dreamscale.robot.observation()

Any robot: named cameras and one state vector, for a deployment shaped to your robot. The deployment sets the camera keys, their order and the state width. Send values in the units the checkpoint was trained on; actions come back the same way. The deployment’s dashboard page shows its keys and loop.
dreamscale.robot.observation

dreamscale.datasets

Keep your LeRobot datasets on Dreamscale and train on them. See Datasets.

dreamscale.datasets.upload()

Upload a folder to a dataset. Unchanged data returns the existing version, and an interrupted upload resumes.
dreamscale.datasets.upload

dreamscale.datasets.import_from()

Copy a Hugging Face dataset in, on our side. With wait=False, returns the running DatasetImport.
dreamscale.datasets.import_from

dreamscale.datasets.get()

A dataset by name, account/name or id. name@N pins the handle to that version.
dreamscale.datasets.get

dreamscale.datasets.list()

dreamscale.datasets.list

dreamscale.datasets.delete()

name deletes the dataset, and name@N one version.
dreamscale.datasets.delete
A Dataset has .id, .name, .full_name, .version (the version the handle points at), .latest_version, .versions, .bytes, .summary, .last_used_at and .data, and the methods refresh(), rename(name), delete(version=None), download(dest, version=None) and train(*, base, max_usd, ...).

dreamscale.trainings

Fine-tune a base model on your LeRobot dataset, on Dreamscale’s GPUs, from Python. It is dreamscale train without the prompt: the price is quoted first, and max_usd is the most a run may cost. See Training.

dreamscale.trainings.create()

Start a training run without a prompt. It refuses to start if the quote is above max_usd. Starting the same dataset with the same settings while that run is still going returns that run instead of a new one.
dreamscale.trainings.create

dreamscale.trainings.get()

dreamscale.trainings.get
Get a training run by its tr_… ID.

Training

A training run.

Errors

Every SDK error is a dreamscale.Error. Each names the problem and the next step, so printing it is usually enough.

Environment variables

Stuck? See Troubleshooting or email team@dreamscalelabs.com.