Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Image

Fluent, immutable builder for declarative sandbox images. Each method returns a new Image instance.

Image.base()

Start from the default OpenSandbox environment (Ubuntu 22.04, Python, Node.js, build tools).
python
from opencomputer import Image image = ( Image.base() .apt_install(["curl", "jq"]) .pip_install(["requests", "pandas"]) .env({"PROJECT_ROOT": "/workspace"}) .workdir("/workspace") )
Returns: Image

Builder Methods

image.apt_install(packages)

body packageslist[str]required
System packages to install via apt-get
Returns: Image

image.pip_install(packages)

body packageslist[str]required
Python packages to install via pip
Returns: Image

image.run_commands(*cmds)

body cmdsstr (variadic)required
Shell commands to run during build
Returns: Image

image.env(vars)

body varsdict[str, str]required
Environment variables to set
Returns: Image

image.workdir(path)

body pathstrrequired
Default working directory
Returns: Image

image.add_file(remote_path, content)

body remote_pathstrrequired
Destination path in the image
body contentstrrequired
File content
Returns: Image

image.add_local_file(local_path, remote_path)

body local_pathstrrequired
Path to the local file
body remote_pathstrrequired
Destination path in the image
Returns: Image

image.add_local_dir(local_path, remote_path)

body local_pathstrrequired
Path to the local directory
body remote_pathstrrequired
Destination path in the image
Returns: Image

image.builder_memory(mb)

Sets the RAM (in MB) used during the build phase. Raise this when a build OOMs (heavy apt/pip/npm). Defaults to 4096. Does not affect the resulting sandbox's memory — size that at create time via memory_mb.
body mbintrequired
Build-phase memory in MB
Returns: Image

Utility Methods

image.to_dict()

Returns the image manifest as a plain dict.
Returns: dict

image.cache_key()

Computes a deterministic SHA-256 hash of the manifest for cache lookups.
Returns: str