- Declarative images — build images with varying dependencies on demand when creating sandboxes
- Pre-built snapshots — create and register ready-to-use snapshots that can be shared across multiple sandboxes
Declarative image building
Build images on-the-fly when creating sandboxes. Ideal for iterating quickly without creating separate snapshots. Declarative images are cached by content hash — identical manifests produce the same image. Subsequent runs reuse the cached image instantly.Sandbox.create({ image, onBuildLog? })
When you pass an image to Sandbox.create(), the server:
- Hashes the image manifest to compute a cache key
- If cached, creates the sandbox from the existing checkpoint instantly
- If not cached, boots a build sandbox, executes each step, checkpoints the result, then creates your sandbox from it
A declarative image definition built with the
Image builder.Callback for streaming build log messages via SSE. Receives step-by-step progress updates during image building.
Creating pre-built snapshots
Create named snapshots that persist permanently and can be shared across sandboxes. Snapshots are visible in the dashboard and don’t need to be rebuilt.new Snapshots(opts?)
snapshots.create(opts)
Creates a pre-built snapshot from a declarative image.
Promise<SnapshotInfo>
snapshots.list()
Returns all named snapshots for the current organization.
Promise<SnapshotInfo[]>
snapshots.get(name)
Gets a snapshot by name.
Snapshot name.
Promise<SnapshotInfo>
snapshots.delete(name)
Deletes a named snapshot. Existing sandboxes created from it are not affected.
Snapshot name to delete.
Promise<void>
Sandbox.create({ snapshot })
Create a sandbox from a pre-built snapshot by name.
Name of a pre-built snapshot to create the sandbox from.
Promise<Sandbox>
Image configuration
TheImage class provides a fluent, immutable API for defining sandbox environments. Each method returns a new Image instance — the original is never modified.
Image.base()
Creates a new image starting from the default OpenSandbox environment (Ubuntu 22.04 with Python, Node.js, build tools, and common utilities).
image.aptInstall(packages)
Install system packages via apt-get.
List of apt package names to install.
image.pipInstall(packages)
Install Python packages via pip.
List of pip package names to install.
image.runCommands(...commands)
Run one or more shell commands during image build.
Shell commands to execute sequentially.
image.env(vars)
Set environment variables. Written to /etc/environment so they’re available in all sessions.
Key-value pairs of environment variables.
image.workdir(path)
Set the default working directory.
Absolute path for the working directory.
image.addFile(remotePath, content)
Embed a file with inline content into the image.
Absolute path inside the sandbox.
String content of the file.
image.addLocalFile(localPath, remotePath)
Read a file from the local machine and embed it into the image.
Path to the file on the local machine.
Absolute path inside the sandbox.
image.addLocalDir(localPath, remotePath)
Recursively read a local directory and embed all files into the image.
Path to the directory on the local machine.
Absolute path inside the sandbox where the directory will be created.
image.toJSON()
Returns the image manifest as a plain object.
Returns: ImageManifest
image.cacheKey()
Computes a deterministic SHA-256 hash of the manifest for cache lookups.
Returns: string
SnapshotInfo
| Field | Type | Description |
|---|---|---|
id | string | Unique snapshot identifier |
name | string | Snapshot name |
status | string | "building", "ready", or "failed" |
contentHash | string | SHA-256 hash of the image manifest |
checkpointId | string | Linked checkpoint ID |
manifest | object | The declarative image manifest |
createdAt | string | ISO 8601 creation timestamp |
lastUsedAt | string | ISO 8601 last usage timestamp |