Skip to content

An open-source, faster Devin alternative

TypeScript

update docs to match new templates system

Brian Reardon666818781946
diff --git a/docs/guides/build-a-lovable-clone.mdx b/docs/guides/build-a-lovable-clone.mdx
index 6ecbb625..9c9f5134 100644
--- a/docs/guides/build-a-lovable-clone.mdx
+++ b/docs/guides/build-a-lovable-clone.mdx
@@ -172,7 +172,7 @@ Several features mentioned as limitations now exist in OpenComputer:
- **In-sandbox agent loop** — [Agent sessions](/agents/overview) now run the Claude Agent SDK inside the sandbox. The agent reads files, runs commands, and iterates on errors locally without leaving the VM. This is the recommended approach for new projects.
- **Preview URL authentication** — `authConfig` on [preview URLs](/sandboxes/preview-urls) supports restricting access. Not full private link sharing yet, but a step toward it.
- **Checkpoints** — [Checkpoint and fork](/sandboxes/checkpoints) workflows are available for snapshotting sandbox state, restoring, and branching.
-- **Custom templates** — Build [custom templates](/sandboxes/templates) from Dockerfiles to skip setup time.
+- **Custom templates** — Define [custom environments](/sandboxes/templates) with the Image builder and pre-built snapshots.
### Still Planned
diff --git a/docs/how-it-works.mdx b/docs/how-it-works.mdx
index 5251674d..4cadfa80 100644
--- a/docs/how-it-works.mdx
+++ b/docs/how-it-works.mdx
@@ -51,15 +51,20 @@ Maximum 10 checkpoints per sandbox.
## Templates
-Templates are built from Dockerfiles, but sandboxes are not containers. The Docker build produces a filesystem image that becomes the VM's root disk. The default template includes Ubuntu, Python 3, Node.js, and common CLI tools.
+Templates define the sandbox environment. The default template includes Ubuntu, Python 3, Node.js, and common CLI tools.
-Custom templates skip repeated setup:
+For custom environments, use the **Image builder** to define dependencies programmatically, or create **pre-built snapshots** for instant reuse:
```typescript
-const sandbox = await Sandbox.create({ template: "my-custom-stack" });
+// On-demand image (built + cached by content hash)
+const image = Image.base().aptInstall(['curl']).pipInstall(['pandas']);
+const sandbox = await Sandbox.create({ image });
+
+// Pre-built snapshot (instant boot)
+const sandbox = await Sandbox.create({ snapshot: 'my-custom-stack' });
```
-See [Templates](/sandboxes/templates) for building your own.
+See [Templates](/sandboxes/templates) for the full guide.
## Networking
diff --git a/docs/reference/api.mdx b/docs/reference/api.mdx
index c9fc1f5d..50281227 100644
--- a/docs/reference/api.mdx
+++ b/docs/reference/api.mdx
@@ -28,7 +28,7 @@ Most operational routes are available on **both** surfaces. Exceptions:
| `POST .../hibernate`, `.../wake` | Yes | — |
| Checkpoint routes | Yes | — |
| Preview URL routes | Yes | — |
-| Template routes | Yes | — |
+| Snapshot routes | Yes | — |
| `POST .../token/refresh` | — | Yes |
| `POST .../timeout` | — | Yes |
| Exec, filesystem, agent, PTY routes | Yes | Yes |
@@ -62,6 +62,8 @@ Create a new sandbox.
| `memoryMB` | int | No | Memory in MB, up to 2048 (default: `512`) |
| `envs` | object | No | Environment variables |
| `metadata` | object | No | Arbitrary key-value pairs |
+| `image` | object | No | Declarative image manifest (see [Image builder](/sandboxes/templates#image-configuration)) |
+| `snapshot` | string | No | Name of a pre-built snapshot (see [Snapshots](#snapshots)) |
**Response** `201`:
@@ -491,46 +493,71 @@ Patches are scripts that run when a sandbox is spawned from a checkpoint. They a
---
-## Templates
+## Snapshots
-Templates are built from Dockerfiles. The Docker build produces a filesystem image that Firecracker boots from directly.
+Snapshots are pre-built sandbox environments created from declarative image manifests. Once built, sandboxes can be created from them instantly.
-### `POST /api/templates` — Build
+### `POST /api/snapshots` — Create
**Request body:**
| Field | Type | Required | Description |
| --- | --- | --- | --- |
-| `name` | string | Yes | Template name |
-| `dockerfile` | string | Yes | Dockerfile content |
-| `tag` | string | No | Image tag (default: `"latest"`) |
+| `name` | string | Yes | Unique snapshot name |
+| `image` | object | Yes | Declarative image manifest (see [Image builder](/sandboxes/templates#image-configuration)) |
**Response** `201`:
```json
{
- "id": "tpl-abc123",
- "name": "my-template",
- "tag": "latest",
- "status": "ready",
- "createdAt": "2025-01-15T10:30:00Z"
+ "id": "snap-abc123",
+ "name": "data-science",
+ "status": "building",
+ "contentHash": "sha256:...",
+ "checkpointId": "",
+ "manifest": { "steps": [...] },
+ "createdAt": "2025-01-15T10:30:00Z",
+ "lastUsedAt": ""
}
```
-Dockerfile templates return `status: "ready"` immediately. Sandbox-snapshot templates transition `processing` → `ready`.
+Status transitions: `building` → `ready` or `failed`.
-### `GET /api/templates` — List
+### `GET /api/snapshots` — List
-**Response** `200`: Array of template objects.
+**Response** `200`: Array of snapshot objects.
-### `GET /api/templates/:name` — Get
+### `GET /api/snapshots/:name` — Get
-**Response** `200`: Template object.
+**Response** `200`: Snapshot object.
-### `DELETE /api/templates/:name` — Delete
+### `DELETE /api/snapshots/:name` — Delete
**Response** `204`: No content.
+### Using snapshots and images with `POST /api/sandboxes`
+
+The create sandbox endpoint accepts `snapshot` or `image` fields in addition to `templateID`:
+
+| Field | Type | Description |
+| --- | --- | --- |
+| `snapshot` | string | Name of a pre-built snapshot — instant boot, no build step |
+| `image` | object | Declarative image manifest — built on first use, cached by content hash |
+
+```bash
+# From a snapshot (instant)
+curl -X POST https://app.opencomputer.dev/api/sandboxes \
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY" \
+ -H "Content-Type: application/json" \
+ -d '{"snapshot": "data-science", "timeout": 600}'
+
+# From a declarative image (built + cached)
+curl -X POST https://app.opencomputer.dev/api/sandboxes \
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY" \
+ -H "Content-Type: application/json" \
+ -d '{"image": {"steps": [{"type": "apt_install", "packages": ["curl"]}]}, "timeout": 600}'
+```
+
---
## PTY
diff --git a/docs/reference/python-sdk.mdx b/docs/reference/python-sdk.mdx
index 69b290b7..97c606ab 100644
--- a/docs/reference/python-sdk.mdx
+++ b/docs/reference/python-sdk.mdx
@@ -10,7 +10,7 @@ pip install opencomputer-sdk
```
```python
-from opencomputer import Sandbox, Template
+from opencomputer import Sandbox, Image, Snapshots
```
---
@@ -31,6 +31,9 @@ Create a new sandbox.
| `api_url` | str | env var | API URL |
| `envs` | dict[str, str] | None | Environment variables |
| `metadata` | dict[str, str] | None | Arbitrary metadata |
+| `image` | Image | None | Declarative image definition (see [Image](#image)) |
+| `snapshot` | str | None | Name of a pre-built snapshot |
+| `on_build_log` | `Callable[[str], None]` | None | Build log callback (when using `image`) |
```python
sandbox = await Sandbox.create(template="my-stack", timeout=600)
@@ -428,41 +431,103 @@ Create an interactive terminal session.
---
-## Template
+## Image
-`Template` is a standalone class (singular, not `Templates`).
+Fluent, immutable builder for declarative sandbox images. Each method returns a new `Image` instance.
-<Warning>
- The Python SDK's `Template` class does not expose a public constructor. Template management is available via the instance methods below (accessed internally), but for direct template operations from Python, use the [HTTP API](/reference/api#templates) instead.
-</Warning>
+### `Image.base(): Image`
-### Instance Methods
+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")
+)
+```
-If you have a `Template` instance (e.g., obtained internally by the SDK):
+### Builder Methods
-#### `await template.build(name, dockerfile): TemplateInfo`
+| Method | Parameters | Description |
+| --- | --- | --- |
+| `apt_install(packages)` | `list[str]` | Install system packages via apt-get |
+| `pip_install(packages)` | `list[str]` | Install Python packages via pip |
+| `run_commands(*cmds)` | `str (variadic)` | Run shell commands during build |
+| `env(vars)` | `dict[str, str]` | Set environment variables |
+| `workdir(path)` | `str` | Set default working directory |
+| `add_file(remote_path, content)` | `str, str` | Embed a file with inline content |
+| `add_local_file(local_path, remote_path)` | `str, str` | Read a local file into the image |
+| `add_local_dir(local_path, remote_path)` | `str, str` | Read a local directory into the image |
-Build a template from a Dockerfile string.
+### `image.to_dict(): dict`
-#### `await template.list(): list[TemplateInfo]`
+Returns the image manifest as a plain dict.
-List all templates.
+### `image.cache_key(): str`
-#### `await template.get(name): TemplateInfo`
+Computes a deterministic SHA-256 hash of the manifest for cache lookups.
-Get a template by name.
+---
-#### `await template.delete(name): None`
+## Snapshots
-Delete a template.
+Standalone class — not a property on Sandbox.
-### TemplateInfo
+### `Snapshots(api_key=..., api_url=...)`
```python
-@dataclass
-class TemplateInfo:
- template_id: str
- name: str
- tag: str
- status: str # "ready" | "building" | "error"
+from opencomputer import Snapshots
+
+snapshots = Snapshots()
+# or with explicit config:
+snapshots = Snapshots(api_key="...", api_url="...")
+```
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| `api_key` | str | API key (falls back to `OPENCOMPUTER_API_KEY` env var) |
+| `api_url` | str | API URL (falls back to `OPENCOMPUTER_API_URL` env var) |
+
+### `await snapshots.create(name, image, on_build_logs=None): dict`
+
+Create a pre-built snapshot from a declarative image.
+
+| Parameter | Type | Required | Description |
+| --- | --- | --- | --- |
+| `name` | str | Yes | Unique snapshot name |
+| `image` | Image | Yes | Declarative image definition |
+| `on_build_logs` | `Callable[[str], None]` | No | Build log streaming callback |
+
+### `await snapshots.list(): list[dict]`
+
+List all snapshots for the current organization.
+
+### `await snapshots.get(name): dict`
+
+Get a snapshot by name.
+
+### `await snapshots.delete(name): None`
+
+Delete a snapshot. Existing sandboxes created from it are not affected.
+
+### SnapshotInfo
+
+Snapshot methods return dicts with these fields:
+
+```python
+{
+ "id": str, # Unique snapshot identifier
+ "name": str, # Snapshot name
+ "status": str, # "building" | "ready" | "failed"
+ "contentHash": str, # SHA-256 hash of the image manifest
+ "checkpointId": str, # Linked checkpoint ID
+ "manifest": dict, # The declarative image manifest
+ "createdAt": str, # ISO 8601 creation timestamp
+ "lastUsedAt": str, # ISO 8601 last usage timestamp
+}
```
diff --git a/docs/reference/typescript-sdk.mdx b/docs/reference/typescript-sdk.mdx
index 3099b9cc..fdbab8de 100644
--- a/docs/reference/typescript-sdk.mdx
+++ b/docs/reference/typescript-sdk.mdx
@@ -10,7 +10,10 @@ npm install @opencomputer/sdk
```
```typescript
-import { Sandbox, Templates } from "@opencomputer/sdk";
+import { Sandbox } from "@opencomputer/sdk";
+// Image and Snapshots are Node.js-only — import directly:
+import { Image } from "@opencomputer/sdk/dist/image.js";
+import { Snapshots } from "@opencomputer/sdk/dist/snapshot.js";
```
---
@@ -33,6 +36,9 @@ Create a new sandbox.
| `metadata` | Record\<string, string\> | — | Arbitrary metadata |
| `cpuCount` | number | — | CPU cores (max 4) |
| `memoryMB` | number | — | Memory in MB (max 2048) |
+| `image` | Image | — | Declarative image definition (see [Image](#image)) |
+| `snapshot` | string | — | Name of a pre-built snapshot |
+| `onBuildLog` | `(log: string) => void` | — | Build log callback (when using `image`) |
```typescript
const sandbox = await Sandbox.create({ template: "my-stack", timeout: 600 });
@@ -179,6 +185,9 @@ interface SandboxOpts {
metadata?: Record<string, string>;
cpuCount?: number;
memoryMB?: number;
+ image?: Image;
+ snapshot?: string;
+ onBuildLog?: (log: string) => void;
}
```
@@ -483,43 +492,101 @@ Create an interactive terminal session.
---
-## Templates
+## Image
+
+Fluent, immutable builder for declarative sandbox images. Each method returns a new `Image` instance.
+
+### `Image.base(): Image`
+
+Start from the default OpenSandbox environment (Ubuntu 22.04, Python, Node.js, build tools).
+
+```typescript
+import { Image } from "@opencomputer/sdk";
+
+const image = Image.base()
+ .aptInstall(['curl', 'jq'])
+ .pipInstall(['requests', 'pandas'])
+ .env({ PROJECT_ROOT: '/workspace' })
+ .workdir('/workspace');
+```
+
+### Builder Methods
+
+| Method | Parameters | Description |
+| --- | --- | --- |
+| `aptInstall(packages)` | `string[]` | Install system packages via apt-get |
+| `pipInstall(packages)` | `string[]` | Install Python packages via pip |
+| `runCommands(...cmds)` | `string[]` | Run shell commands during build |
+| `env(vars)` | `Record<string, string>` | Set environment variables |
+| `workdir(path)` | `string` | Set default working directory |
+| `addFile(remotePath, content)` | `string, string` | Embed a file with inline content |
+| `addLocalFile(localPath, remotePath)` | `string, string` | Read a local file into the image |
+| `addLocalDir(localPath, remotePath)` | `string, string` | Read a local directory into the image |
+
+### `image.toJSON(): ImageManifest`
+
+Returns the image manifest as a plain object.
+
+### `image.cacheKey(): string`
+
+Computes a deterministic SHA-256 hash of the manifest for cache lookups.
+
+---
+
+## Snapshots
Standalone class — not a property on Sandbox.
-### `new Templates(apiUrl, apiKey)`
+### `new Snapshots(opts?)`
```typescript
-import { Templates } from "@opencomputer/sdk";
+import { Snapshots } from "@opencomputer/sdk";
-const templates = new Templates("https://app.opencomputer.dev", apiKey);
+const snapshots = new Snapshots();
+// or with explicit config:
+const snapshots = new Snapshots({ apiKey: "...", apiUrl: "..." });
```
-### `templates.build(name, dockerfile): Promise<TemplateInfo>`
+| Parameter | Type | Description |
+| --- | --- | --- |
+| `apiKey` | string | API key (falls back to `OPENCOMPUTER_API_KEY` env var) |
+| `apiUrl` | string | API URL (falls back to `OPENCOMPUTER_API_URL` env var) |
-Build a template from a Dockerfile string.
+### `snapshots.create(opts): Promise<SnapshotInfo>`
-### `templates.list(): Promise<TemplateInfo[]>`
+Create a pre-built snapshot from a declarative image.
-List all templates.
+| Parameter | Type | Required | Description |
+| --- | --- | --- | --- |
+| `name` | string | Yes | Unique snapshot name |
+| `image` | Image | Yes | Declarative image definition |
+| `onBuildLogs` | `(log: string) => void` | No | Build log streaming callback |
+
+### `snapshots.list(): Promise<SnapshotInfo[]>`
+
+List all snapshots for the current organization.
-### `templates.get(name): Promise<TemplateInfo>`
+### `snapshots.get(name): Promise<SnapshotInfo>`
-Get a template by name.
+Get a snapshot by name.
-### `templates.delete(name): Promise<void>`
+### `snapshots.delete(name): Promise<void>`
-Delete a template.
+Delete a snapshot. Existing sandboxes created from it are not affected.
### Types
-#### TemplateInfo
+#### SnapshotInfo
```typescript
-interface TemplateInfo {
- templateID: string;
+interface SnapshotInfo {
+ id: string;
name: string;
- tag: string;
- status: string; // "ready" | "building" | "error"
+ status: string; // "building" | "ready" | "failed"
+ contentHash: string;
+ checkpointId: string;
+ manifest: object;
+ createdAt: string;
+ lastUsedAt: string;
}
```
diff --git a/docs/sandboxes/templates.mdx b/docs/sandboxes/templates.mdx
index 29297f91..d33e7eb6 100644
--- a/docs/sandboxes/templates.mdx
+++ b/docs/sandboxes/templates.mdx
@@ -1,168 +1,271 @@
---
title: "Templates"
-description: "Pre-built base images for sandboxes"
+description: "Define sandbox environments programmatically with the Image builder and Snapshots"
---
-A template is a pre-built filesystem image that sandboxes start from. Build custom templates from Dockerfiles to skip repeated setup — install your dependencies once, then create sandboxes instantly from that template.
+Templates provide a code-first approach to defining sandbox environments. Instead of configuring images manually, you define them programmatically using the SDK.
+
+The system supports two workflows:
+
+1. **Declarative images** — build images with varying dependencies _on demand_ when creating sandboxes
+2. **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.
<CodeGroup>
```typescript TypeScript
-import { Sandbox, Templates } from "@opencomputer/sdk";
-
-const templates = new Templates(apiUrl, apiKey);
-await templates.build("my-stack", `
-FROM ubuntu:22.04
-RUN apt-get update && apt-get install -y nodejs npm
-RUN npm install -g pnpm
-WORKDIR /app
-`);
-
-// Create a sandbox with the custom template
-const sandbox = await Sandbox.create({ template: "my-stack" });
-await sandbox.exec.run("pnpm --version"); // already installed
+import { Sandbox, Image } from '@opencomputer/sdk';
+
+// Define an image with packages, env vars, and files
+const image = Image.base()
+ .aptInstall(['curl', 'jq'])
+ .pipInstall(['requests', 'pandas'])
+ .env({ PROJECT_ROOT: '/workspace' })
+ .workdir('/workspace');
+
+// Create a sandbox — the image is built on first run, cached after
+const sandbox = await Sandbox.create({
+ image,
+ timeout: 300,
+ onBuildLog: (log) => console.log(`build: ${log}`),
+});
+
+const result = await sandbox.exec.run('which curl');
+console.log(result.exitCode); // 0
+```
+
+```python Python
+from opencomputer import Sandbox, Image
+
+# Define an image with packages, env vars, and files
+image = (
+ Image.base()
+ .apt_install(["curl", "jq"])
+ .pip_install(["requests", "pandas"])
+ .env({"PROJECT_ROOT": "/workspace"})
+ .workdir("/workspace")
+)
+
+# Create a sandbox — the image is built on first run, cached after
+sandbox = await Sandbox.create(
+ image=image,
+ timeout=300,
+ on_build_log=lambda log: print(f"build: {log}"),
+)
+
+result = await sandbox.exec.run("which curl")
+print(result.exit_code) # 0
```
```bash curl
-# Build template
-curl -X POST https://app.opencomputer.dev/api/templates \
+curl -X POST https://app.opencomputer.dev/api/sandboxes \
-H "X-API-Key: $OPENCOMPUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
- "name": "my-stack",
- "dockerfile": "FROM ubuntu:22.04\nRUN apt-get update && apt-get install -y nodejs npm\nRUN npm install -g pnpm\nWORKDIR /app"
+ "image": {
+ "steps": [
+ {"type": "apt_install", "packages": ["curl", "jq"]},
+ {"type": "pip_install", "packages": ["requests", "pandas"]},
+ {"type": "env", "vars": {"PROJECT_ROOT": "/workspace"}},
+ {"type": "workdir", "path": "/workspace"}
+ ]
+ },
+ "timeout": 300
}'
-
-# Create sandbox from template
-curl -X POST https://app.opencomputer.dev/api/sandboxes \
- -H "X-API-Key: $OPENCOMPUTER_API_KEY" \
- -H "Content-Type: application/json" \
- -d '{"templateID": "my-stack"}'
```
</CodeGroup>
-<Note>
- `Templates` is a standalone class, not a property on Sandbox. TypeScript exports `Templates` (plural), Python exports `Template` (singular).
-</Note>
+When you pass an `image` to `Sandbox.create()`, the server:
-<Note>
- The Python `Template` class does not have a public constructor. Use the HTTP API for template management from Python, or use `Sandbox.create(template="my-stack")` after building the template via HTTP.
-</Note>
+1. Hashes the image manifest to compute a **cache key**
+2. If cached, creates the sandbox from the existing checkpoint instantly
+3. If not cached, boots a build sandbox, executes each step, checkpoints the result, then creates your sandbox from it
-## Default Template
+## Creating pre-built snapshots
-Sandboxes use the default template when no template is specified. It includes:
+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.
-- **Ubuntu 22.04**
-- **Python 3** with pip, venv, setuptools
-- **Node.js 20 LTS** with npm
-- **Build tools:** build-essential, cmake, pkg-config
-- **CLI tools:** git, git-lfs, curl, wget, jq, rsync, htop, tree
-- **Editors:** nano, vim-tiny
-- **Database:** sqlite3
-- **Networking:** openssh-client, iproute2, net-tools, dnsutils
-- **Claude Agent SDK** and claude-code (pre-installed for agent sessions)
+<CodeGroup>
-## API Reference
+```typescript TypeScript
+import { Image, Snapshots } from '@opencomputer/sdk';
-### Build Template
+const snapshots = new Snapshots();
-Templates are built from Dockerfiles. The Docker build produces a filesystem image that Firecracker boots as the VM's root disk.
+// Define the image
+const image = Image.base()
+ .aptInstall(['python3-pip'])
+ .pipInstall(['pandas', 'numpy', 'scikit-learn'])
+ .workdir('/workspace');
-<CodeGroup>
+// Create a named snapshot with build log streaming
+await snapshots.create({
+ name: 'data-science',
+ image,
+ onBuildLogs: (log) => console.log(`build: ${log}`),
+});
-```typescript TypeScript
-const templates = new Templates(apiUrl, apiKey);
-const info = await templates.build("node20-pnpm", `
-FROM ubuntu:22.04
-RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
-RUN apt-get install -y nodejs && npm install -g pnpm
-`);
-console.log(info.status); // "ready"
+// Now create sandboxes from the snapshot — instant, no build step
+const sandbox = await Sandbox.create({ snapshot: 'data-science' });
+```
+
+```python Python
+from opencomputer import Image, Snapshots
+
+snapshots = Snapshots()
+
+# Define the image
+image = (
+ Image.base()
+ .apt_install(["python3-pip"])
+ .pip_install(["pandas", "numpy", "scikit-learn"])
+ .workdir("/workspace")
+)
+
+# Create a named snapshot with build log streaming
+await snapshots.create(
+ name="data-science",
+ image=image,
+ on_build_logs=lambda log: print(f"build: {log}"),
+)
+
+# Now create sandboxes from the snapshot — instant, no build step
+sandbox = await Sandbox.create(snapshot="data-science")
```
```bash curl
-curl -X POST https://app.opencomputer.dev/api/templates \
+# Create a named snapshot
+curl -X POST https://app.opencomputer.dev/api/snapshots \
-H "X-API-Key: $OPENCOMPUTER_API_KEY" \
-H "Content-Type: application/json" \
- -d '{"name": "node20-pnpm", "dockerfile": "FROM ubuntu:22.04\n..."}'
+ -d '{
+ "name": "data-science",
+ "image": {
+ "steps": [
+ {"type": "apt_install", "packages": ["python3-pip"]},
+ {"type": "pip_install", "packages": ["pandas", "numpy", "scikit-learn"]},
+ {"type": "workdir", "path": "/workspace"}
+ ]
+ }
+ }'
+
+# Create sandbox from the snapshot — instant
+curl -X POST https://app.opencomputer.dev/api/sandboxes \
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY" \
+ -H "Content-Type: application/json" \
+ -d '{"snapshot": "data-science"}'
```
</CodeGroup>
-Dockerfile templates return `status: "ready"` immediately. Sandbox-snapshot templates transition `processing` → `ready`.
-
-### List Templates
+### Managing snapshots
<CodeGroup>
```typescript TypeScript
-const all = await templates.list();
-```
+const snapshots = new Snapshots();
-```bash curl
-curl https://app.opencomputer.dev/api/templates \
- -H "X-API-Key: $OPENCOMPUTER_API_KEY"
+// List all snapshots
+const list = await snapshots.list();
+for (const s of list) {
+ console.log(`${s.name} — ${s.status}`);
+}
+
+// Get a specific snapshot
+const snapshot = await snapshots.get('data-science');
+console.log(snapshot.status); // "ready"
+
+// Delete a snapshot
+await snapshots.delete('data-science');
```
-</CodeGroup>
+```python Python
+snapshots = Snapshots()
-### Get Template
+# List all snapshots
+snapshot_list = await snapshots.list()
+for s in snapshot_list:
+ print(f"{s['name']} — {s['status']}")
-<CodeGroup>
+# Get a specific snapshot
+snapshot = await snapshots.get("data-science")
+print(snapshot["status"]) # "ready"
-```typescript TypeScript
-const info = await templates.get("my-stack");
+# Delete a snapshot
+await snapshots.delete("data-science")
```
```bash curl
-curl https://app.opencomputer.dev/api/templates/my-stack \
+# List all snapshots
+curl https://app.opencomputer.dev/api/snapshots \
-H "X-API-Key: $OPENCOMPUTER_API_KEY"
-```
-</CodeGroup>
-
-### Delete Template
-
-<CodeGroup>
-
-```typescript TypeScript
-await templates.delete("my-stack");
-```
+# Get a specific snapshot
+curl https://app.opencomputer.dev/api/snapshots/data-science \
+ -H "X-API-Key: $OPENCOMPUTER_API_KEY"
-```bash curl
-curl -X DELETE https://app.opencomputer.dev/api/templates/my-stack \
+# Delete a snapshot
+curl -X DELETE https://app.opencomputer.dev/api/snapshots/data-science \
-H "X-API-Key: $OPENCOMPUTER_API_KEY"
```
</CodeGroup>
-### Using with Sandbox.create
-
-Pass the template name when creating a sandbox:
+---
-<CodeGroup>
+## Default template
-```typescript TypeScript
-const sandbox = await Sandbox.create({ template: "my-stack" });
-```
+Sandboxes use the default template when no image or snapshot is specified. It includes:
-```python Python
-sandbox = await Sandbox.create(template="my-stack")
-```
-
-</CodeGroup>
+- **Ubuntu 22.04**
+- **Python 3** with pip, venv, setuptools
+- **Node.js 20 LTS** with npm
+- **Build tools:** build-essential, cmake, pkg-config
+- **CLI tools:** git, git-lfs, curl, wget, jq, rsync, htop, tree
+- **Editors:** nano, vim-tiny
+- **Database:** sqlite3
+- **Networking:** openssh-client, iproute2, net-tools, dnsutils
+- **Claude Agent SDK** and claude-code (pre-installed for agent sessions)
-## TemplateInfo
+---
-| Field | TypeScript | Python | Description |
-| --- | --- | --- | --- |
-| Template ID | `templateID` | `template_id` | Unique identifier |
-| Name | `name` | `name` | Template name |
-| Tag | `tag` | `tag` | Image tag (default: `"latest"`) |
-| Status | `status` | `status` | `ready`, `building`, or `error` |
+## Image configuration
+
+The `Image` class provides a fluent, immutable API for defining sandbox environments. Each method returns a **new** `Image` instance — the original is never modified.
+
+| Method | Description |
+| --- | --- |
+| `Image.base()` | Start from the default OpenSandbox environment |
+| `.aptInstall(packages)` / `.apt_install(packages)` | Install system packages via apt-get |
+| `.pipInstall(packages)` / `.pip_install(packages)` | Install Python packages via pip |
+| `.runCommands(...cmds)` / `.run_commands(*cmds)` | Run shell commands during build |
+| `.env(vars)` | Set environment variables (written to `/etc/environment`) |
+| `.workdir(path)` | Set default working directory |
+| `.addFile(path, content)` / `.add_file(path, content)` | Embed a file with inline content |
+| `.addLocalFile(local, remote)` / `.add_local_file(local, remote)` | Read a local file into the image |
+| `.addLocalDir(local, remote)` / `.add_local_dir(local, remote)` | Read a local directory into the image |
+| `.toJSON()` / `.to_dict()` | Return the image manifest |
+| `.cacheKey()` / `.cache_key()` | Compute SHA-256 content hash |
+
+## 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 |
<Tip>
- Full reference: [TypeScript SDK](/reference/typescript-sdk#templates) · [Python SDK](/reference/python-sdk#template) · [HTTP API](/reference/api#templates).
+ Full SDK reference: [TypeScript SDK](/sdks/typescript/templates) · [Python SDK](/sdks/python/templates) · [HTTP API](/reference/api#snapshots).
</Tip>