Skip to main content
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.
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
Templates is a standalone class, not a property on Sandbox. TypeScript exports Templates (plural), Python exports Template (singular).
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.

Default Template

Sandboxes use the default template when no template is specified. It includes:
  • 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)

API Reference

Build Template

Templates are built from Dockerfiles. The Docker build produces a filesystem image that Firecracker boots as the VM’s root disk.
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"
Dockerfile templates return status: "ready" immediately. Sandbox-snapshot templates transition processingready.

List Templates

const all = await templates.list();

Get Template

const info = await templates.get("my-stack");

Delete Template

await templates.delete("my-stack");

Using with Sandbox.create

Pass the template name when creating a sandbox:
const sandbox = await Sandbox.create({ template: "my-stack" });

TemplateInfo

FieldTypeScriptPythonDescription
Template IDtemplateIDtemplate_idUnique identifier
NamenamenameTemplate name
TagtagtagImage tag (default: "latest")
Statusstatusstatusready, building, or error
Full reference: TypeScript SDK · Python SDK · HTTP API.