Skip to main content

Python SDK for Dream Engine — frontier video world models, served by Dream Engines.

Project description

dream-engine — Python SDK for Dream Engine

dream-engine is the official Python SDK for Dream Engine, the inference engine for video world models from Dream Engines. Run frontier world models (DreamDojo · GR-1, more on the way) over HTTP with a small, typed client.

Status: v0.4.0 — stable release. Rollout, AsyncClient, typed errors, retries, predict_batch, and bundled examples are all available. See sdk/python/CHANGELOG.md for the full version history.

Install

pip install dream-engine

For mp4 → numpy frame decoding:

pip install "dream-engine[decode]"

Quickstart

import dream
import numpy as np
from PIL import Image

client = dream.Client()                              # reads DREAM_API_KEY + DREAM_BASE_URL
model  = client.models.get("dreamdojo-2b-gr1")       # ModelHandle (typed; checks the catalog)
print(model.action_dim, model.resolution)            # 384, (480, 640) — flat accessors

img  = Image.open("start.png")
acts = np.load("actions.npy")                        # (48, 384) float32

rollout = model.predict(start_frame=img, actions=acts)
print("frames:", rollout.frames, "cost:", rollout.cost_usd)
rollout.save("rollout.mp4")

# Access decoded frames as a numpy array (requires [decode] extra):
print(rollout.video().shape)  # (T, H, W, 3) uint8

You can also pass file paths or raw bytes:

# Paths (str or Path) — SDK reads the file and encodes for the wire
rollout = model.predict(start_frame="start.png", actions="actions.npy")

Set DREAM_API_KEY in your environment, or pass api_key=... to the Client(...) constructor. Mint keys at https://dreamengines.run/dashboard.

List the catalog

for handle in client.models.list():
    print(handle.slug, handle.spec.name, "active" if handle.active else "")

Visual MPC — K candidates in one server roundtrip

import numpy as np

candidates = np.random.randn(8, 48, 384).astype(np.float32)  # (K, T, action_dim)

batch = model.predict_batch(start_frame=img, actions=candidates)
print(batch.batch_size, batch.engine_wall_ms)
for r in batch.rollouts:
    print(r.cost_usd)

Wire-level access (advanced)

If you want to skip the ModelHandle layer and call the endpoint with pre-encoded bytes:

# Low-level: bypasses active-spec check and input coercion
response = client.predict(frame_bytes=frame_bytes, actions_bytes=actions_bytes)

Prefer model.predict(start_frame=…, actions=…) for most use cases. The wire-level path is for scripts that already have wire-ready bytes and don't need the typed Rollout result.

License

Apache-2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dream_engine-0.4.1.tar.gz (572.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dream_engine-0.4.1-py3-none-any.whl (577.4 kB view details)

Uploaded Python 3

File details

Details for the file dream_engine-0.4.1.tar.gz.

File metadata

  • Download URL: dream_engine-0.4.1.tar.gz
  • Upload date:
  • Size: 572.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for dream_engine-0.4.1.tar.gz
Algorithm Hash digest
SHA256 3798451e67339e2b2ed3c5fa5daac3c7f23cdb34b02cc4398a838e0d4ef17983
MD5 3f3568d4cd5db7478fdeb4657a326788
BLAKE2b-256 b4ee37698c454ee0b028bf2047c6699ca9cb466bf7d87020a3f3c28de4732e14

See more details on using hashes here.

File details

Details for the file dream_engine-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: dream_engine-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 577.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for dream_engine-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 394dbd2c4e2e86862280a21e7f60c6f9c7469c0a1f0e8f9258c54db89c7e3b13
MD5 3f5cc65df732d86adb63b34b17530eeb
BLAKE2b-256 77345f293883aa712286bbec145a6911f027574738a82a0c2aa445a68d026257

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page