Migrate from Modal
Map Modal sandbox calls to Platinum SDK calls, port Modal Image builds to templates, and see what behaves differently.
Last updated
Platinum runs untrusted and AI-generated code in isolated sandboxes. This page maps Modal sandbox calls to Platinum SDK calls, for Modal's Python and JavaScript SDKs. It is for engineers who know Modal and are new to Platinum.
Install the SDK
Install the Platinum SDK in place of the modal package.
npm install @platinum-dev/sdkpip install "platinum-sdk>=0.7"npm install -g @platinum-dev/cli# Nothing to install. Send requests to $PT_API_URL with your API key.Authenticate
Modal reads MODAL_TOKEN_ID and MODAL_TOKEN_SECRET, or a token in ~/.modal.toml. Platinum reads one API key from PT_TOKEN. Create a key in the dashboard or with pt login. See API keys.
export PT_TOKEN=pt_live_…
export PT_API_URL=https://api.platinum.dev| Variable | Read by | Meaning |
|---|---|---|
PT_TOKEN | TypeScript SDK, Python SDK, pt CLI | The API key. |
PLATINUM_API_KEY | pt CLI only | The API key. It wins over PT_TOKEN. |
PLATINUM_API_URL, else PT_API_URL | TypeScript SDK, Python SDK, pt CLI | The API base URL. The default is https://api.platinum.dev. The cURL examples below read PT_API_URL. platinum-sdk before 0.7.0 has no hosted default and reads only PT_API_URL: upgrade it. |
With PT_TOKEN set, new Platinum() (TypeScript) and Platinum() (Python) need no arguments. new Platinum() replaces new ModalClient(). Platinum has no App, so drop modal.App.lookup(). A sandbox belongs to the organization of your API key.
Map Modal calls to Platinum
Modal creates a sandbox inside an App. Platinum creates it through a client: client.sandboxes.create(). In the table, sbx is a sandbox handle, r is an exec result, and p is a managed process.
| Modal | Platinum TypeScript | Platinum Python | Page |
|---|---|---|---|
modal.App.lookup(name, create_if_missing=True) | No App. Create a client: new Platinum() | No App. Create a client: Platinum() | Authenticate |
Sandbox.create(app=app) / modal.sandboxes.create(app, image) | client.sandboxes.create({}, { waitForRunning: true }) | client.sandboxes.create(wait_for_running=True) | Create |
image= at create | client.sandboxes.create({ template: "my-agent" }), or { image: builder } | client.sandboxes.create(template="my-agent"), or image=builder | Templates |
cpu=1.0, memory=2048 / cpu: 1, memoryMiB: 2048 | client.sandboxes.create({ cpu: 2, ram_mb: 2048 }) | client.sandboxes.create(cpu=2, ram_mb=2048) | Create |
env={...} at create, or Secret.from_dict({...}) | client.sandboxes.create({ env: { KEY: "value" } }) | client.sandboxes.create(env={"KEY": "value"}) | Create |
region= | client.sandboxes.create({ region: "eu-west" }) | client.sandboxes.create(region="eu-west") | Regions |
Sandbox.from_id(id) / modal.sandboxes.fromId(id) | client.sandboxes.connect(id) | client.sandboxes.connect(id) | Get |
Sandbox.from_name(app, name) | No lookup by name. See Differences. | No lookup by name. See Differences. | List |
Sandbox.list(app_id=...) | client.sandboxes.list({ state: "running" }) | client.sandboxes.list(state="running") | List |
sb.exec("python", "-c", code) / sb.exec(["python", "-c", code]) | sbx.exec(["python3", "-c", code]) | sbx.exec(["python3", "-c", code]) | Run a command |
p.stdout.read(), p.wait(), p.returncode | r.stdout, r.exit_code. exec returns at exit. | r.stdout, r.exit_code. exec returns at exit. | Run a command |
sb.exec(..., workdir=, env=, timeout=) | sbx.process.start({ cmd, cwd, env, timeoutMs }) | sbx.process.start(cmd, cwd=..., env=..., timeout_ms=...) | Managed processes |
for line in p.stdout / for await (const chunk of p.stdout) | for await (const ev of p.stream()) | for ev in p.stream(): | Managed processes |
p.stdin.write(data), p.stdin.write_eof() | p.stdin(data), p.closeStdin() | p.stdin(data), p.close_stdin() | Managed processes |
sb.filesystem.write_text(data, path) / writeText(data, path) | sbx.files.write(path, data) | sbx.files.write(path, data) | Read and write |
read_text(path) · read_bytes(path) | sbx.files.read(path) returns Uint8Array | sbx.files.read(path) returns bytes | Read and write |
copy_from_local · copy_to_local | sbx.files.write and sbx.files.read with local bytes, or pt sandbox cp | sbx.files.write and sbx.files.read with local bytes, or pt sandbox cp | Read and write |
list_files · make_directory · remove · stat | files.list · files.mkdir · files.delete · files.stat | files.list · files.mkdir · files.delete · files.stat | Filesystem |
filesystem.watch(path) | sbx.files.watch(path) (async iterator) | sbx.files.watch(path) (generator) | Watch for changes |
encrypted_ports=[8000], then sb.tunnels()[8000].url | client.sandboxes.create({ expose: [{ port: 8000 }] }), then sbx.exposedUrl(8000). After create: (await sbx.expose(8000)).url | client.sandboxes.create(expose=[{"port": 8000}]), then sbx.exposed_url(8000). After create: sbx.expose(8000)["url"] | Expose ports at create |
unencrypted_ports=[port] | sbx.expose(port, { protocol: "tcp" }) | sbx.expose(port, protocol="tcp") | Expose a raw TCP port |
block_network=True / blockNetwork: true | client.sandboxes.create({ allowInternetAccess: false }) | client.sandboxes.create(allow_internet_access=False) | Block internet access |
outbound_domain_allowlist · outbound_cidr_allowlist | client.sandboxes.create({ network: { allowOut, denyOut } }) | client.sandboxes.create(network={"allow_out": ..., "deny_out": ...}) | Allow only some destinations |
timeout= / timeoutMs | No equivalent. See Differences. | No equivalent. See Differences. | Retention |
idle_timeout= / idleTimeoutMs | client.sandboxes.create({ auto_stop_minutes: 15 }) (stops after 15 idle minutes) | client.sandboxes.create(auto_stop_minutes=15) (stops after 15 idle minutes) | Retention |
sb.terminate() | sbx.delete() (alias sbx.kill()) | sbx.delete() (alias sbx.kill()) | Delete |
sb.snapshot_filesystem(), then Sandbox.create(image=snapshot) | sbx.snapshot(), then sbx.clone({ snapshotId }) | sbx.snapshot(), then sbx.clone(snapshot_id=...) | Clone or fork |
| Memory snapshots | No new sandbox from memory. sbx.stop() and sbx.start() keep memory for the same sandbox. | No new sandbox from memory. sbx.stop() and sbx.start() keep memory for the same sandbox. | Stop and start |
Volume.from_name(name, create_if_missing=True) | client.volumes.open(name) | client.volumes.open(name) | Volumes |
volumes={"/data": vol} | client.sandboxes.create({ volumes: { "/data": vol } }) | client.sandboxes.create(volumes={"/data": vol}) | Mount volumes |
vol.with_mount_options(sub_path=..., read_only=True) | vol.subdir(path), vol.readOnly() | vol.subdir(path), vol.read_only() | Mount volumes |
sync /data in the sandbox | sbx.volumes.get("/data").commit() | sbx.volumes.get("/data").commit() | Commit and pull |
sb.reload_volumes() | sbx.volumes.get("/data").pull() | sbx.volumes.get("/data").pull() | Commit and pull |
secrets=[modal.Secret.from_name(name)] | client.sandboxes.create({ secrets: ["name"] }) for an HTTP header credential. Else use env. | client.sandboxes.create(secrets=["name"]) for an HTTP header credential. Else use env. | Secrets |
set_tags(tags) | client.sandboxes.create({ metadata }), at create only | client.sandboxes.create(metadata={...}), at create only | Create |
gpu="A100" | No general equivalent. See Differences. | No general equivalent. See Differences. | Differences |
modal.Image builders | Template | Template | Templates |
Port the common flows
Create a sandbox, run a command, and delete it
Modal uses App.lookup(), Sandbox.create(), sb.exec(), and sb.terminate().
import { Platinum } from "@platinum-dev/sdk";
const client = new Platinum(); // reads PT_TOKEN and PT_API_URL
const sbx = await client.sandboxes.create({ template: "pt-base" }, { waitForRunning: true });
const r = await sbx.exec(["python3", "-c", "print(2+2)"]);
console.log(r.exit_code, r.stdout);
await sbx.delete();from platinum import Platinum
client = Platinum() # reads PT_TOKEN and PT_API_URL
sbx = client.sandboxes.create(template="pt-base", wait_for_running=True)
r = sbx.exec(["python3", "-c", "print(2+2)"])
print(r.exit_code, r.stdout)
sbx.delete()SBX=$(pt sandbox create -t pt-base -q)
pt sandbox exec $SBX 'python3 -c "print(2+2)"'
pt sandbox rm $SBXSBX=$(curl -sS -X POST "$PT_API_URL/v1/sandboxes?wait_for_state=running" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{"template":"pt-base"}' | jq -r .id)
curl -sS -X POST "$PT_API_URL/v1/sandboxes/$SBX/exec" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{"cmd":["python3","-c","print(2+2)"]}' | jq -r .result.stdout
curl -sS -X DELETE "$PT_API_URL/v1/sandboxes/$SBX" -H "Authorization: Bearer $PT_TOKEN"Modal's exec takes each argument separately. Platinum takes one argv array, or one string that runs with sh -c. exec returns when the command exits, so you need no wait().
Write and read a file
Modal uses sb.filesystem.write_text(), read_text(), and list_files(). Platinum puts the path first.
await sbx.files.write("/workspace/test.txt", "Hello World!\n");
const text = new TextDecoder().decode(await sbx.files.read("/workspace/test.txt"));
const entries = await sbx.files.list("/workspace");sbx.files.write("/workspace/test.txt", "Hello World!\n")
text = sbx.files.read("/workspace/test.txt").decode()
entries = sbx.files.list("/workspace")pt sandbox fs write $SBX /workspace/test.txt 'Hello World!'
pt sandbox fs read $SBX /workspace/test.txt
pt sandbox fs ls $SBX /workspacecurl -sS -X PUT "$PT_API_URL/v1/sandboxes/$SBX/files?path=/workspace/test.txt" \
-H "Authorization: Bearer $PT_TOKEN" --data-binary 'Hello World!'
curl -sS "$PT_API_URL/v1/sandboxes/$SBX/files?path=/workspace/test.txt" -H "Authorization: Bearer $PT_TOKEN"
curl -sS "$PT_API_URL/v1/sandboxes/$SBX/files/list?path=/workspace" -H "Authorization: Bearer $PT_TOKEN"files.read returns bytes, so decode them for text. A write creates missing parent directories. To copy a local file in or out, use pt sandbox cp.
Run a long command and stream its output
Modal uses sb.exec(), reads p.stdout line by line, and calls p.wait(). On Platinum, start a managed process.
const p = await sbx.process.start({
cmd: "for i in 1 2 3; do echo step $i; sleep 10; done",
cwd: "/tmp",
env: { LOG_LEVEL: "info" },
});
for await (const ev of p.stream()) {
if (ev.type === "stdout") process.stdout.write(ev.text);
}
const done = await p.wait();
console.log(done.exit_code);p = sbx.process.start("for i in 1 2 3; do echo step $i; sleep 10; done",
cwd="/tmp", env={"LOG_LEVEL": "info"})
for ev in p.stream():
if ev.type == "stdout":
print(ev.data, end="")
done = p.wait(timeout_ms=600_000)
print(done.exit_code)# No dedicated CLI command for managed processes. Use the API passthrough.
H=$(pt api POST /v1/sandboxes/$SBX/processes \
-d '{"cmd":"for i in 1 2 3; do echo step $i; sleep 10; done","cwd":"/tmp","env":{"LOG_LEVEL":"info"}}' | jq -r .handle)
pt api /v1/sandboxes/$SBX/processes/$H --query "wait_ms=55000" | jq .exit_code
pt api /v1/sandboxes/$SBX/processes/$H/logs | jq -r .stdoutH=$(curl -sS -X POST "$PT_API_URL/v1/sandboxes/$SBX/processes" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{"cmd":"for i in 1 2 3; do echo step $i; sleep 10; done","cwd":"/tmp","env":{"LOG_LEVEL":"info"}}' \
| jq -r .handle)
curl -sS "$PT_API_URL/v1/sandboxes/$SBX/processes/$H?wait_ms=55000" \
-H "Authorization: Bearer $PT_TOKEN" | jq .exit_code
curl -sS "$PT_API_URL/v1/sandboxes/$SBX/processes/$H/logs" \
-H "Authorization: Bearer $PT_TOKEN" | jq -r .stdoutexec times out after 30 s by default, and one call waits about 85 s at most. A managed process has no deadline unless you set timeoutMs (timeout_ms in Python). It keeps the last 256 KiB of each stream, so read its output while it runs. In Python, wait() gives up after 5 minutes by default and leaves the process running.
Expose a port
Modal uses encrypted_ports at create, then reads the URL from sb.tunnels().
await sbx.process.start({ cmd: "python3 -m http.server 8000" });
const { url } = await sbx.expose(8000);
console.log(url);sbx.process.start("python3 -m http.server 8000")
print(sbx.expose(8000)["url"])pt api POST /v1/sandboxes/$SBX/processes -d '{"cmd":"python3 -m http.server 8000"}'
pt sandbox expose $SBX 8000curl -sS -X POST "$PT_API_URL/v1/sandboxes/$SBX/processes" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{"cmd":"python3 -m http.server 8000"}'
curl -sS -X POST "$PT_API_URL/v1/sandboxes/$SBX/expose" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{"port":8000}' | jq -r .urlThe URL carries a token that expires after 1 day. A Modal tunnel URL has no token. For the same behavior, pass public: true to expose.
A request to the URL starts a stopped sandbox. See Use preview URLs.
Snapshot a sandbox and start a copy
Modal uses sb.snapshot_filesystem(), then passes the result to Sandbox.create(image=...).
const snap = await sbx.snapshot();
const c = await sbx.clone({ snapshotId: snap.id });
const copy = await client.sandboxes.connect(c.id);
await copy.waitRunning();snap = sbx.snapshot()
c = sbx.clone(snapshot_id=snap["id"])
new_sbx = client.sandboxes.connect(c["id"])
new_sbx.wait_running()pt sandbox snapshot $SBX
pt sandbox clone $SBX # clones the latest snapshotSNAP=$(curl -sS -X POST "$PT_API_URL/v1/sandboxes/$SBX/snapshot" \
-H "Authorization: Bearer $PT_TOKEN" | jq -r .id)
curl -sS -X POST "$PT_API_URL/v1/sandboxes/$SBX/clone" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d "{\"snapshot_id\":\"$SNAP\"}" | jq -r .idA snapshot holds the disk only, so the copy cold-boots. Processes and memory do not carry over. /tmp starts empty on every cold boot, so its files do not carry over either. Keep files you need under /workspace. A snapshot stays until you delete it, and it bills while it exists. sbx.fork() takes a snapshot and clones it in one call.
Mount a volume
Modal uses Volume.from_name(..., create_if_missing=True) and volumes= at create.
const vol = await client.volumes.open("data"); // get or create
const sbx = await client.sandboxes.create(
{ template: "pt-base", volumes: { "/data": vol } },
{ waitForRunning: true },
);vol = client.volumes.open("data") # get or create
sbx = client.sandboxes.create(template="pt-base", volumes={"/data": vol},
wait_for_running=True)pt api PUT /v1/volumes/data # get or create
SBX=$(pt sandbox create -t pt-base -v data:/data -q)curl -sS -X PUT "$PT_API_URL/v1/volumes/data" -H "Authorization: Bearer $PT_TOKEN"
curl -sS -X POST "$PT_API_URL/v1/sandboxes?wait_for_state=running" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{"template":"pt-base","volumes":{"/data":{"volume":"data"}}}'pt-base mounts volumes. A custom template built before volumes launched fails the mount with template_lacks_volume_support: rebuild it. Writes commit about every 5 seconds, on sync, and when the sandbox stops or is deleted. Other sandboxes see them after a pull(), which replaces reload_volumes().
Templates
A Modal Image is a chain of build steps in code. A Platinum template is an image plus default CPU, RAM, and disk. Pick one of the ports below.
Build from an image
Use this when your Modal code calls Image.from_registry(tag). Pin the tag: the build rejects floating tags such as latest.
import { Platinum, Template } from "@platinum-dev/sdk";
const client = new Platinum();
const tpl = await Template.fromImage("ubuntu:24.04")
.build(client, { name: "my-agent", default_cpu: 2, default_ram_mb: 1024 });from platinum import Platinum, Template
client = Platinum()
tpl = Template.from_image("ubuntu:24.04").build(
client, "my-agent", default_cpu=2, default_ram_mb=1024)pt template build my-agent --image ubuntu:24.04 --cpu 2 --ram 1024 --waitcurl -X POST "$PT_API_URL/v1/templates/from-image" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{"name":"my-agent","image":"ubuntu:24.04","default_cpu":2,"default_ram_mb":1024}'The image's own CMD or ENTRYPOINT runs at boot. See Build from an image.
Translate the Image chain into steps
Use this when your Modal code builds the image with methods. Write each method as a declarative builder step.
| Modal | Platinum step (TypeScript / Python) |
|---|---|
Image.from_registry(tag) / modal.images.fromRegistry(tag) | Template.fromImage(ref) / Template.from_image(ref) |
Image.debian_slim(python_version="3.13") | Template.fromPythonImage("3.13-slim") / Template.from_python_image("3.13-slim") |
.pip_install(...), .uv_pip_install(...) | .pipInstall([...]) / .pip_install([...]) |
.apt_install(...) | .aptInstall([...]) / .apt_install([...]) |
.run_commands(cmd, ...) | .runCmd(cmd) / .run_cmd(cmd), one call per command |
.env({"KEY": "value"}) | .env("KEY", "value"), one call per variable |
.workdir(path) | .workdir(path) |
.add_local_file(local, remote, copy=True) | .copy(local, remote), up to 256 KiB per file |
.add_local_dir(...) | No step. Write the files after create, or keep them on a volume. |
.entrypoint([...]), .cmd([...]) | .entrypoint(cmd), one command string |
.run_function(fn) | No step. Run a script with .runCmd() / .run_cmd(). |
.dockerfile_commands(...), Image.from_dockerfile(path) | No Dockerfile parser. Build the image in a registry, or see Build a Dockerfile from git. |
runtime="vm" to run dockerd | .containerRuntime() / .container_runtime() |
Image.from_name(name) | template: "name" at create |
image.build(app) | .build(client, { name }) / .build(client, name) |
For example, take this Modal image:
image = (
modal.Image.debian_slim(python_version="3.13")
.apt_install("git", "curl")
.uv_pip_install("pandas", "requests")
.env({"LOG_LEVEL": "info"})
.workdir("/app")
)The same image as a step chain:
import { Platinum, Template } from "@platinum-dev/sdk";
const client = new Platinum();
const tpl = await Template.fromPythonImage("3.13-slim")
.aptInstall(["git", "curl"])
.pipInstall(["pandas", "requests"])
.env("LOG_LEVEL", "info")
.workdir("/app")
.build(client, { name: "my-agent", default_cpu: 2, default_ram_mb: 1024 });
if (tpl.state === "failed") throw new Error(tpl.build_logs);from platinum import Platinum, Template
client = Platinum()
tpl = (Template.from_python_image("3.13-slim")
.apt_install(["git", "curl"])
.pip_install(["pandas", "requests"])
.env("LOG_LEVEL", "info")
.workdir("/app")
.build(client, "my-agent", default_cpu=2, default_ram_mb=1024))
if tpl["state"] == "failed":
raise RuntimeError(tpl["build_logs"])# No CLI command for a step chain. Put the cURL body in spec.json and use the API passthrough.
pt api POST /v1/templates/from-spec -d @spec.jsoncurl -X POST "$PT_API_URL/v1/templates/from-spec" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{
"name": "my-agent",
"base_image": "python:3.13-slim",
"steps": [
{ "op": "apt", "packages": ["git", "curl"] },
{ "op": "pip", "packages": ["pandas", "requests"] },
{ "op": "env", "key": "LOG_LEVEL", "value": "info" },
{ "op": "workdir", "path": "/app" }
],
"default_cpu": 2,
"default_ram_mb": 1024
}'A failed build does not throw. Check state before you use the template.
Build inline at create
Modal builds an Image when Sandbox.create() first uses it. To keep that pattern, pass the step chain as image at create.
import { Platinum, Template } from "@platinum-dev/sdk";
const client = new Platinum();
const image = Template.fromPythonImage("3.13-slim").pipInstall(["pandas"]);
const sbx = await client.sandboxes.create(
{ image },
{ waitForRunning: true, waitTimeoutMs: 600_000 },
);from platinum import Platinum, Template
client = Platinum()
image = Template.from_python_image("3.13-slim").pip_install(["pandas"])
sbx = client.sandboxes.create(image=image, wait_for_running=True,
wait_timeout_ms=600_000)# No CLI flag for an inline image spec. Put the cURL body in body.json and use the API passthrough.
pt api POST /v1/sandboxes --query "wait_for_state=running" -d @body.jsoncurl -X POST "$PT_API_URL/v1/sandboxes?wait_for_state=running&wait_timeout_ms=60000" \
-H "Authorization: Bearer $PT_TOKEN" -H "Content-Type: application/json" \
-d '{
"image": {
"base_image": "python:3.13-slim",
"steps": [{ "op": "pip", "packages": ["pandas"] }]
}
}'An identical spec reuses the cached build. An inline build must finish within 300 s. For a large image, build a named template first. See Build inline at sandbox create.
Build a Dockerfile from git
Modal's Image.from_dockerfile(path) reads a local Dockerfile. When the apps feature is enabled for your org, Platinum builds a Dockerfile from a git repo: pt template build my-agent --repo <url> --dockerfile Dockerfile. See Build from git.
When the template is ready, create sandboxes with template: "my-agent". This replaces image= in Sandbox.create().
Differences
Warning: a Platinum sandbox has no lifetime deadline, so it does not end when Modal's timeout would. A stopped sandbox still bills disk. Delete sandboxes you no longer need, or set auto_stop_minutes and auto_delete_days at create.
| Area | Modal | Platinum |
|---|---|---|
| Lifetime | timeout is the maximum lifetime. The default is 5 minutes, and the maximum is 24 hours. | A sandbox stays until you delete it, or until its retention timers do. The SDKs set the timers at create only. See Retention. |
| Idle | idle_timeout terminates an idle sandbox. | auto_stop_minutes stops an idle sandbox. Stop keeps memory and processes where it can. start(), resume(), or a request to a preview URL brings it back. See What a stop saved. |
| Apps | Each sandbox belongs to an App. | No App. A sandbox belongs to the organization of your API key. To group sandboxes, set parent_id at create. See Parent and child sandboxes. |
| Entrypoint | Sandbox.create("cmd", ...) runs a command. The sandbox finishes when it exits. sb.returncode holds its exit code. | Create takes no command. The template's entrypoint runs at boot. For one job, start a managed process and wait() for it. |
| Names | Sandbox.from_name(app, name) finds a named sandbox. | name is a label, unique among your active sandboxes. The SDKs and the API address a sandbox by id. The pt CLI accepts a name. |
| Tags | set_tags() works at any time. Sandbox.list() filters by tags. | metadata (up to 16 KiB) is set at create and comes back on reads. list has no metadata filter. |
| Readiness | readiness_probe and wait_until_ready() wait for your app. | A sandbox is running when it boots, not when your app is ready. Poll your app's health check with exec. |
| Commands | exec has no deadline by default. p.stdout streams output. | exec returns all output at exit. It times out after 30 s by default, and one call waits about 85 s at most. Stream output from a managed process. |
| Per-command options | exec takes workdir, env, and secrets. | exec takes none of these. A managed process takes cwd and env. exec also accepts a shell string such as cd /app && make. |
| CPU and memory | cpu counts physical cores, and one core is 2 vCPUs. It can be fractional. memory is in MiB. | cpu counts whole vCPUs, so Modal cpu=1.0 is cpu: 2. Modal memory=2048 is ram_mb: 2048. |
| Files | Reads go up to 5 GB. write_text(data, path) puts the data first. | files.write(path, data) puts the path first. One write carries at most 128 MiB less 4 KiB, and one read returns at most 256 MiB. See Limits. |
| Public URL | Anyone with a tunnel URL reaches the port. create_connect_token() adds a token. | expose() returns a URL with a token by default. The token expires after 1 day. Pass public: true for a URL without a token. |
| Snapshots | snapshot_filesystem() returns an Image. It expires after 30 days by default. Memory snapshots restore into a new sandbox. | snapshot() holds the disk only. It stays until you delete it. clone() and fork() cold-boot the copy. Only stop() and start() keep memory. See Compare what survives what. |
| Directory snapshots | snapshot_directory() and mount_image() copy one directory. | No directory snapshot. Keep the directory on a volume: it has history, tags, and fork. |
| Secrets | A Secret becomes environment variables in the sandbox. | A secret never enters the sandbox. The egress proxy writes it into an HTTP header for exact hosts, over HTTPS on port 443. For a value your code must read, use env. See Know what a secret can carry. |
| Volumes | Changes commit in the background. reload() shows other writers' commits. | Each mount is a private working copy. Commits run about every 5 seconds, on sync, and at stop, delete, or detach. pull() brings in other commits. Snapshots and forks do not include volumes. |
| GPUs | gpu="A100" picks a GPU type and count. | GPU sandboxes are not generally available. gpus sets a count, not a type. An org without GPU access gets 403 gpu_not_enabled. |
| Templates | Each Image method is a cached layer. from_dockerfile() parses a Dockerfile. from_registry() takes registry credentials. | A step chain is one spec, cached by its content. The SDK has no Dockerfile parser. Image tags must be pinned. No build field carries registry credentials. |
| Billing | CPU bills per physical core and memory per GiB, per second. | Each vCPU and each GiB of RAM bills per second while the sandbox runs. A stopped sandbox bills only its disk and snapshots. See Billing. |
Next steps
- Sandboxes: lifecycle states, retention timers, stop and start
- Managed processes: servers, builds, and other long-running work
- Filesystem: search, replace, and watch files
- Networking: preview URLs, raw TCP ports, and outbound rules
- Volumes and Secrets
- Templates and the declarative builder
- TypeScript SDK, Python SDK, and CLI references