Sandbox
Isolated machines on demand, for AI agents, code interpreters, previews and CI.
A sandbox is an isolated machine you create through an API. Create one, run commands, read and write files, open a port as a URL, then throw it away. Use them for:
- AI agents that write and run code.
- Code interpreters.
- Previews of a branch or a change.
- CI jobs and other code you don't trust.
Sandboxes run on your own servers. They show in the same dashboard as your services and databases.
How sandboxes run
Sandboxes run on their own sandbox servers, outside your clusters and build servers. A sandbox server runs no k3s or Docker, just a small Pyo daemon, so a busy sandbox can't slow down your services.
On a server with KVM, each sandbox is its own microVMA very small virtual machine that boots in milliseconds, with its own kernel. on Firecracker, with its own kernel. On a server without KVM, like a cloud VPS, each sandbox runs under gVisor, which gives it a kernel of its own in user space. Sandboxes never run as plain containers.
Your code asks Pyo to create a sandbox, then runs commands and moves files with a short-lived token Pyo signs. Where those calls go depends on the sandbox server:
- With Tailscale, the server answers on your tailnet, and your code talks to it directly. So the code that runs commands in a sandbox, and the browser you open its terminal in, need to be on your tailnet too. Pyo isn't in the way of each command.
- Without Tailscale, the calls go through Pyo. They work from anywhere that reaches Pyo. See Without Tailscale.
Tailscale is optional. Sandboxes keep running while Pyo itself restarts. Only the ports you open are on the web.
The sandbox server gets its work from Pyo over HTTPS. Pyo never connects to it. See How Pyo and the server talk.
KVM or gVisor
Each time a sandbox server starts, Pyo checks what it can run:
- Firecracker on KVM. The server has KVM and a test microVM boots in under 300 ms. This is the fastest.
- Firecracker on nested KVM. The server is itself a VM with KVM passed through. The test boot is slower, so sandboxes start slower too.
- gVisor. The server has no usable KVM, like most cloud VPSs, but can run gVisor.
A server with neither is turned away when it joins, with the reason. If a server loses KVM, it becomes a gVisor server at its next start. The Clusters page shows each sandbox server's runtime with a one-line summary. So do pyo sandbox servers ls and runtime in the API.
A sandbox's Isolation is Auto by default, which picks Firecracker first. VM only (isolation: "vm") never runs it on gVisor.
Which server a sandbox runs on
Pyo picks a server that's up, can run the sandbox's isolation and network, and has the memory for it. It prefers Firecracker, then a server with a snapshot of the template at that size, then the one with the most room.
To choose one yourself, pick it under Server in New sandbox, or pass server, a server's name or id, to the SDK, the API, create_sandbox in MCP or --server in the CLI. The sandbox then runs only there. If that server can't take it, Pyo says why, like "sandbox-1 has no room for 2 GB. Pick another server or a smaller size."
What gVisor can't do
Sandboxes on gVisor run the same templates and have the same commands, files, terminals, ports, network rules, limits, lifetimes and pause. These differ from Firecracker:
- Cold starts. A sandbox starts from its template's disk in about 40 ms. Firecracker restores a running snapshot, so a template can't have a process already warm in it on gVisor.
- Slower system calls. Each command and each process start costs more. A command takes about 5 ms instead of under 1 ms, and starting Python takes 4 to 5 times as long. For a code interpreter, keep one interpreter running and send it code.
- Not every Linux feature. gVisor runs most programs, but some system calls and parts of
/procand/sysare missing. Docker doesn't fully work inside a sandbox, and nothing can run a VM inside one. - Pause needs the same gVisor release. A paused sandbox resumes only under the gVisor release it was paused under. An update that changes it ends the pauses on that server.
- No VM only. A sandbox created with
isolation: "vm"never runs on a gVisor server. - More disk for the server. gVisor's files take about 180 MB on the server.
Add a sandbox server
Open Sandboxes in the dashboard, choose New sandbox, then Add server. A team with no sandboxes and no sandbox server yet also has Add a sandbox server on that page. Team owners and admins can add one. There are two ways:
- Cloud provider. Pyo buys a server for you and sets it up. It needs Tailscale set up in Pyo.
- Command line. You run one command on a server you have. It works with Tailscale or without it.
Pyo Cloud has only the command line. See On Pyo Cloud.
Cloud provider
Pyo makes the server in your team's Hetzner project, the same way it makes a cluster's servers there:
- Pick the provider. If your team hasn't connected Hetzner yet, paste a project API token with Read & Write right there. See Make a token.
- Name the server, and give it an edge domain if you want sandbox ports on the web.
- Pick a location and a server type. Pyo reads the types, their vCPUs, memory, disk and monthly prices from Hetzner as you pick. Prices are before VAT and include the IPv4 address.
- Choose Create. Pyo shows the monthly price and asks once more.
The page then follows the server: Creating, Booting, Joining, Ready. On its first boot the server joins your tailnet with a single-use key, gets a one-time join code from Pyo over the tailnet and runs pyo-server with it. Then it joins Pyo over HTTPS, like a server you add from the command line. Nothing else secret is in its setup. If your tailnet has Tailnet Lock on, Pyo shows the command to sign the server. You can leave the page while it sets up. The Sandboxes page shows its progress too.
Hetzner Cloud servers have no KVM, so they run sandboxes on gVisor. Pyo puts them behind a Hetzner firewall that lets in only the web (80 and 443) and Tailscale, and they run nothing else.
Removing the server in Pyo ends its sandboxes, takes it off your tailnet and deletes it at Hetzner. Pyo shows the monthly cost that stops and asks first.
Command line
A server of your own needs:
- Linux on x86-64 or arm64, with kernel 5.10 or newer and cgroup v2
- KVM for Firecracker, or else root for gVisor
- a machine of its own. A machine with k3s on it is turned away.
Choose Command line. The form shows the command at once, under Name and Edge domain:
- Change the name if you like, and give the server an edge domain if you want sandbox ports on the web. The command follows both fields as you type.
- Copy the command and run it on the new machine as root.
- The form says Waiting for sbx-1 to join…, then that the server is ready. New sandbox then creates a sandbox on it.
The command works once, for 15 minutes. When it expires, the form says This command expired. Choose Get a new command for a fresh one. Each change of a field makes a new command too, and the one before stops working.
To leave before the server joins:
- Cancel takes the server back. Nothing is left of it in Pyo.
- Finish later keeps the server and opens it on the Clusters page. Run the command you copied before it expires, or choose Reset access there for a new one.
Leaving the page any other way takes the server back too. One that's still there is removed a day after its last command expired, unless it joined.
The CLI gives the same command:
pyo sandbox servers add sbx-1The command looks like this:
curl -fsSL https://pyo.dev/v/0.53.0/server.sh | bash -s -- sandbox pyos1_eyJweW9VcmwiOi...It downloads pyo-server for your Pyo's release, checks it and runs it. The token carries Pyo's address, the server's ID and name, its one-time code, Pyo's command key, the edge domain when you gave one and, with Tailscale, a single-use Tailscale key. pyo-server token show prints it with the secrets hidden. See The token.
With Tailscale, it joins your tailnet, gets an HTTPS certificate for its name there, installs the daemon, Firecracker and the guest kernel, checks what the server can run and joins Pyo. A server without KVM gets gVisor too, and is checked again.
The server reaches Pyo at Pyo's address on your tailnet. A team with a tailnet of its own reaches Pyo at its public address instead. If Pyo has none, adding the server says so. Turn on Public dashboard on the Tailscale card first.
Your tailnet needs HTTPS certificates turned on in its DNS settings. Pyo's own names on your tailnet use them too.
A machine that's on a tailnet already, but not as one of Pyo's servers, is left as it is. The command stops and says to run tailscale logout, then the same command again.
The server's daemon answers only on your tailnet, at https://<name>.<tailnet>.ts.net:7443. Only ports 80 and 443 are public, for the edge proxy that serves sandbox ports.
With ufw active, the command opens 7443 on tailscale0 and closes 7070, which Pyo used before 0.52.0.
Sandbox servers show on the Clusters page as their own group, with their runtime, CPUs, memory, disk and sandboxes.
Without Tailscale
A sandbox server needs no Tailscale and no cluster. Nobody picks how a server joins. Pyo picks each time it makes a join command:
- With Tailscale, when your team has Tailscale set up, or Pyo's own server is on a tailnet.
- Without Tailscale, when neither is.
The form then says "Without Tailscale, the terminal and files go through Pyo. The desktop needs Tailscale." The command's token then carries no Tailscale key, and pyo-server token show shows relay: true.
It installs and changes nothing of Tailscale. The server joins Pyo with its one-time code alone, at Pyo's public HTTPS address. If Pyo has none, adding the server says "Pyo has no HTTPS address this server can reach. Open the public dashboard or set up Tailscale, then add the server again."
Nothing on the server listens for browsers and SDKs. The server opens its own connections to Pyo and takes their calls there. With ufw active, the command opens only 80 and 443, for the edge. It ends with "The terminal and files open in Pyo."
The Clusters page shows Proxied where a server's tailnet name would be: its calls are proxied by Pyo. So does a sandbox's page.
What works without Tailscale
| Without Tailscale | |
|---|---|
| Creating, pausing, resuming and deleting sandboxes | Works |
| Commands, files, the terminal and port calls, from the dashboard, the SDK and the CLI | Work, through Pyo |
| MCP tools | Work, through Pyo as before |
| Opened ports on the edge domain | Work, straight to the server on ports 80 and 443 |
base, desktop and templates from public images | Work |
| The desktop and Browser | Need Tailscale |
A sandbox's private web pages at /v1/sandboxes/{id}/web/{port}/ | Need Tailscale |
| Templates from Pyo's registry | Need Tailscale. The registry is on Pyo's tailnet |
| A server from a cloud provider | Needs Tailscale |
On a sandbox whose server has no Tailscale, the desktop buttons are off and say Needs Tailscale.
A web page on another origin than Pyo's can't make calls through Pyo. To call a sandbox from a browser page of your own, the server needs Tailscale.
What passes through Pyo
For a server without Tailscale, the bytes of each terminal, command and file call pass through Pyo. With Tailscale they go from your device to the server over your tailnet, and Pyo never carries them.
To keep Pyo out of that path, set up Tailscale, then move the server onto your tailnet.
Pyo takes only the sandbox's token on these calls, and checks it before it asks the server anything. The server checks the token again. Pyo answers with headers of its own, so a browser never renders or runs what a sandbox sends back.
Without Tailscale, the one-time code alone guards the join. With Tailscale, Pyo also checks that your tailnet lists the server. Someone who gets a code before you run the command could join a machine of their own with it. Your server's join then fails. Choose Reset access on the server and run the new command.
Limits through Pyo
| Limit | Value |
|---|---|
| A request or response body | 64 MiB |
| A call | 10 minutes |
| A terminal or other WebSocket | 4 hours |
| Calls open at once, for a server | 64 |
| Calls a minute, for a sandbox | 600 |
| Calls a minute, for a server | 1,800 |
Pyo waits 20 seconds for the server to take a call. Then it answers "The sandbox server didn't answer. Is it online?" The dashboard says "Can't reach the sandbox server. Is it online?"
A request over 64 MiB is refused. A response over it is cut off. Over 64 open calls, Pyo answers "This sandbox server has too many calls open through Pyo. Try again in a moment."
On Pyo Cloud, a plain command call that sends nothing back for 100 seconds is cut off, before the 10 minutes are up. That's exec in the SDK and pyo sandbox exec in the CLI. Calls on a WebSocket aren't affected: spawn and pty in the SDK, pyo sandbox shell in the CLI and the dashboard's terminal. Use spawn for a command that stays quiet that long.
Move a server onto your tailnet
- Set up Tailscale for your team on Integrations.
- On the Clusters page, choose Reset access on the server's menu. Pyo stops taking the server's key at once and shows a new command, whose token now carries a Tailscale key.
- Run the command on the server as root. It installs Tailscale, joins your tailnet, gets the server's HTTPS certificate and joins Pyo again.
Its sandboxes keep running. The terminal, files and desktop then open on your tailnet.
It works the other way too. When there's no Tailscale any more, Reset access gives a command without a Tailscale key. It removes the server's certificate and its renewal timer. Tailscale itself stays on the machine.
If Tailscale is set up but can't be used, like when the cluster that keeps it is offline, Pyo doesn't add the server without Tailscale. It says what's wrong instead.
On Pyo Cloud
A Pyo Cloud team adds a sandbox server with one command. The server needs no cluster. Once it joined, it counts as a server on your bill.
- Open Sandboxes, choose New sandbox, then Add server. Team owners and admins can add one.
- The form shows the command as the page opens. Change the name if you like, and give the server an edge domain if you want sandbox ports on the web.
- Run the command on the server. It asks for root itself. It works once, for 15 minutes.
pyo sandbox servers add sbx-1 gives the same command. In the API it's createSandboxJoinCode, in place of addSandboxServer.
How the server joins depends on your team's Tailscale on Integrations:
- With it, the command carries a single-use key from your team's Tailscale. The server joins your tailnet, gets an HTTPS certificate for its name there, then joins Pyo Cloud over HTTPS. The cluster that keeps your Tailscale has to be connected when you add the server.
- Without it, the command carries no Tailscale key. The server joins Pyo Cloud with its one-time code alone. See Without Tailscale.
Either way the server reaches Pyo Cloud over HTTPS, at the address your clusters' agents use. It gets its work there with a key of its own, and every command is signed for that one server. Pyo Cloud never connects to the server and never reaches into your tailnet. See How Pyo and the server talk.
With Tailscale, the desktop, terminal and files open at the server's own name on your tailnet, like https://sbx-1.tail1234.ts.net:7443. So they open only from devices on your team's tailnet. Elsewhere the dashboard says Opens from devices on your team's tailnet. The SDK and the CLI's exec, shell and cp use that address too. MCP tools go through Pyo Cloud, so they work from anywhere.
Without Tailscale, the terminal and files go through Pyo Cloud, and the desktop needs Tailscale.
Pyo Cloud doesn't have:
- Servers from a cloud provider. Pyo Cloud doesn't make sandbox servers at Hetzner. Buy a server at any provider and run the command on it.
- Shared servers. Each team has only its own sandbox servers. A self-hosted Pyo can also have servers of the installation, which every team may use.
- Templates from Pyo's registry. Pyo Cloud has no registry of its own. Make your own templates from public images.
How the files are checked
The sandbox server's files come with each Pyo release. server.sh checks pyo-server before it runs. Before anything changes on the server, pyo-server checks the release's release.json against its Sigstore signature, for exactly its own release. Then it checks the files against the SHA-256 that release.json lists for that architecture in its sandbox field, and gVisor's files against its sandboxGvisor field. gVisor is a pinned release, checked against its own SHA-512 when Pyo's release is made. If anything doesn't match, nothing is installed.
Options
Pyo's command carries everything that joins the server. You can add these after the token. They change how it installs:
| Option | What it does |
|---|---|
--edge-domain D | Serve sandbox ports at <port>-<sandbox>.D on ports 80 and 443. Also PYO_SANDBOX_EDGE_DOMAIN. See Edge domain. |
--edge-cert FILE | The certificate for *.D, as PEM with the full chain. Default /etc/pyo-sandbox/edge/cert.pem. |
--edge-key FILE | Its private key. Default /etc/pyo-sandbox/edge/key.pem. |
--bundle FILE | Sandbox files from a file or URL instead of the release. Also PYO_SANDBOX_BUNDLE. They're checked against --bundle-sha256, or else against the signed release.json. |
--bundle-sha256 SUM | The SHA-256 to check --bundle against. Also PYO_SANDBOX_BUNDLE_SHA256. |
--gvisor-bundle X | gVisor's files from a file or URL instead of the release, for a server without KVM. Also PYO_SANDBOX_GVISOR_BUNDLE. They're checked against the signed release.json. |
--dev | Skip the check, for files you built yourself. Also PYO_SANDBOX_DEV=1. |
server.sh takes two more, which Pyo adds when they're needed:
| Option | What it does |
|---|---|
--version X | The Pyo release whose pyo-server and sandbox files to install, like 0.53.0. The copies of server.sh on pyo.dev and in Pyo know their release without it. |
--dev-commit C | For a development build of Pyo: the pyo-server and files CI published for commit C on dev, instead of a release's. Their release.json must be signed by Pyo's development workflow on dev and name that commit, and the files must match the SHA-256 it lists. A development build's command uses it in place of --version. |
Update the daemon
Run this on the server as root:
sudo pyo-server updateIt brings pyo-server to the release your Pyo runs, then updates the daemon. Running sandboxes keep running. The server keeps the way it joined, with or without Tailscale. A gVisor server gets the release's gVisor too. See Update.
A server set up before 0.53.0 has no pyo-server yet. Run server.sh of your Pyo's release with sandbox and no token, which installs pyo-server and updates the daemon:
curl -fsSL https://pyo.dev/v/0.53.0/server.sh | bash -s -- sandboxTake it off a machine
To take Pyo off the server, remove it on the Clusters page or with pyo sandbox servers rm. Pyo stops taking the server's key at once. Its sandboxes keep running there until their lifetime ends, or until you run this on it:
sudo pyo-server uninstallIt stops the daemon and ends its sandboxes. It removes the daemon's files in /usr/local/lib/pyo-sandbox, /etc/pyo-sandbox and /var/lib/pyo-sandbox, its units, its firewall rules and /var/lib/pyo-server. Tailscale stays, and so does the system user pyo-sandbox.
A server set up before 0.53.0 takes the script's command:
curl -fsSL https://your-pyo/install/sandbox.sh | bash -s -- --uninstallHow Pyo and the server talk
- The join. The server makes a key of its own and joins Pyo with the one-time code. With Tailscale, Pyo takes the join only from a server your tailnet lists as one of Pyo's. Without Tailscale, the code alone guards it.
- Its work. The server asks Pyo for its commands and sends back their results and a report every 15 seconds. It signs each request with its key. The key opens only that server's commands, and lasts a day. The server renews it by itself.
- Signed commands. Pyo signs each command with its own key, for that one server. The server checks the signature, the server it names and that it's new before it runs it. It takes Pyo's key from the command you ran.
- Reset access. Choose Reset access on the server's menu on the Clusters page. Pyo stops taking the server's key at once, and gives you a new command for the same server. Its sandboxes keep running. Run the command on the server to join it again. A server that was off for more than a day needs this too, since its key ran out. The new command joins it on your tailnet when there's Tailscale, without it otherwise. So it also moves a server onto your tailnet.
Update a server
A sandbox server that joined before Pyo 0.52.0 needs an update. Pyo no longer reaches it the old way, so it takes no commands until you update it. The Clusters page shows Needs update and "This server needs an update. Press Update to reconnect it." Each sandbox on it shows the same. Until then, creating, deleting, pausing or resuming its sandboxes, opening their ports, the terminal, files and the desktop all say so. Its sandboxes keep running.
Choose Update on the server or on one of its sandboxes. Pyo shows a command for the same server. Run it on the server as root. The server joins over HTTPS and takes commands again, and its sandboxes keep running. The command joins it on your tailnet when there's Tailscale, without it otherwise. pyo sandbox servers ls shows needs update for such a server.
A command with --pyo no longer works. Running it, or updating such a server with pyo-server sandbox and no token, says to press Update in Pyo.
Edge domain
Opened ports are served by the sandbox server's edge proxy, at https://<port>-<sandbox>.<edge domain>, like https://3000-sbx-abc.sbx.example.com. Give a server an edge domain when you add it, under Edge domain, or with --edge-domain. Without one, ports can't be opened on that server.
The edge domain needs a wildcard DNS record, *.sbx.example.com, pointing at the server's public address. HTTPS needs a wildcard certificate for it.
With Cloudflare
When your Cloudflare connection can edit the domain's zone, the server's menu on the Clusters page offers:
- Create DNS record, which adds the wildcard record pointing at the server's public addresses, not proxied by Cloudflare. A record already on that name is never changed.
- Get certificate, which gets a wildcard certificate from Let's Encrypt and puts it on the server. Pyo renews it 30 days before it runs out. Renew certificate renews it now.
Pyo gets the certificate itself, so your Cloudflare token never goes to the sandbox server.
Your own certificate
Without Cloudflare, put a wildcard certificate on the server yourself, at /etc/pyo-sandbox/edge/cert.pem and /etc/pyo-sandbox/edge/key.pem, or the paths you gave with --edge-cert and --edge-key. The edge serves it within a minute, with no restart. Until there's a certificate, ports are served over plain HTTP.
Templates
A sandbox starts from a sandbox template, made from a container image. Find them under Templates, in the sidebar's Sandboxes menu.
The base template
Every Pyo has base, a template Pyo makes for you. A sandbox starts from it when you don't name a template, and New sandbox picks it first. It's listed under Sandbox templates from the start, even before you add a sandbox server.
It's Ubuntu 24.04 LTS with the tools coding agents expect:
- System: git, curl, wget, jq, ripgrep, zip, unzip, rsync, openssh-client, sudo, vim, nano and the usual network tools.
- Build tools: build-essential, pkg-config, cmake and ninja.
- Python: Python 3.12 with pip, venv and uv.
- JavaScript: Node.js 24 LTS with npm, pnpm, Bun and Deno.
- CLIs: GitHub's
ghand the Docker CLI with buildx and compose. There's no Docker daemon in it, so pointDOCKER_HOSTat one. - Coding agents: Claude Code, Codex and opencode.
Commands run as root in /root. pip installs into the system Python, since a sandbox is thrown away. The full list with versions is in pyo-sandbox-images.
base belongs to the installation, so every team has it. It can't be deleted, and no other template can be named base.
The desktop template
desktop is base with a desktop and a browser, for agents that use a browser and for people who want to watch them. Its sandboxes get 2 CPUs and 2 GiB of memory unless you ask for more.
- The screen: a desktop you watch and use in your browser, served by voxl on port 6080 inside the sandbox. Choose Desktop in the sandboxes list or Open desktop on the sandbox's page. It opens over HTTPS on your tailnet, so it needs Tailscale set up in Pyo. Until then, Open desktop is greyed out. On a server that joined without Tailscale it says Needs Tailscale. Set up Tailscale, then choose Reset access on the server.
- The browser: Google Chrome on x86-64 and Chromium on arm64. Drive it over the Chrome DevTools Protocol at
127.0.0.1:9222inside the sandbox, with Playwright or Puppeteer. Browser in the sandboxes list opens the screen with the browser in front.
Nothing starts until it's used: the first look at the screen or the first CDP connection starts the desktop, then the browser.
pyo sandbox create desktopLike base, it belongs to the installation and can't be deleted.
On first use
A sandbox server doesn't get base or desktop when it joins. It makes each the first time a sandbox needs it there: it downloads the image, about 0.9 GB for base and 1.25 GB for desktop, then unpacks it and boots it once. The create waits for that and then starts the sandbox, so the first sandbox from it on a server takes longer. Later ones on that server start at once.
While it waits, the dashboard says Getting base ready on sandbox-1… with how far it got, and the templates list shows each server's progress. Two sandboxes created at once on that server wait for the same download. The templates page says base is Ready to use and lists the servers that have it.
If a server isn't done after 4 minutes, the create stops with "base is still getting ready on sandbox-1. Try again in a minute." The server keeps going, so the next try starts once it's done.
How base and desktop update
Their images come from pyo-sandbox-images, ghcr.io/upsetdev/pyo-sandbox-images/base and ghcr.io/upsetdev/pyo-sandbox-images/desktop. They're rebuilt every week with Ubuntu's security updates. Each build is signed, and so is the list of its images, images.json, which names each image by digest.
Pyo reads the latest images.json from GitHub every hour and uses it only when its signature checks out. Each Pyo release also carries the one of when it was made, so a Pyo that can't reach GitHub still has images. PYO_UPDATE_CHECK=off stops the hourly check too. When a newer build comes out:
- Each sandbox server that has the template makes the new one in the background. Servers that never used it wait for their first sandbox from it.
- New sandboxes start from it once it's ready on their server. Until then they start from the one before.
- Running and paused sandboxes keep the one they started from. The server deletes it once no sandbox uses it.
A template never moves back to an older build.
Your own templates
Make a template from any image:
pyo sandbox templates create node-22 node:22The image can be public on any registry, or in Pyo's registry. A server without Tailscale can't pull from Pyo's registry, which is on Pyo's tailnet. Every sandbox server that may use the template pulls the image and unpacks it. A Firecracker server then boots it once and saves a snapshot to start sandboxes from. A gVisor server starts each sandbox from the unpacked disk. A template is ready once one server has it. Each template shows its state on each server: pending, building (pulling, unpacking or snapshotting), ready or failed, with its size once ready.
To add your own tools to base, build on its image and push the result to Pyo's registry:
FROM ghcr.io/upsetdev/pyo-sandbox-images/base:24.04
RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client \
&& rm -rf /var/lib/apt/lists/*
RUN uv pip install --system pandasPyo doesn't use an image's USER, ENV or WORKDIR yet. Commands run as root in /root, with PATH set to the usual system folders, so put tools in /usr/local/bin or /usr/bin.
An image may take up to 10 GiB, and the server needs the disk space to unpack it. A server builds one template at a time.
Templates belong to your team, or to the installation, which every team can use. Deleting a template removes it from the servers that made it.
Networking
A sandbox has the internet by default. Choose No network (network: "none") for a sandbox with no network at all. Opened ports still work then, since the edge reaches them through the sandbox server, not the network.
A sandbox with network can't reach:
- the sandbox server itself, on any of its addresses
- your tailnet
- other sandboxes
- private and link-local ranges, like
10.0.0.0/8,192.168.0.0/16and169.254.169.254 - anything over IPv6
DNS goes to 1.1.1.1 and 8.8.8.8. Nothing from outside can open a connection into a sandbox. Only replies come back.
Sandboxes get addresses from 198.18.0.0/16, a range nothing routes. If that overlaps the server's own networks, the daemon won't turn networking on. To change the range or the DNS servers, or to block more ranges, edit /etc/pyo-sandbox/local.json on the server and restart pyo-sandbox.
Docker and ufw on the server
Docker and ufw set the server's forwarding policy to drop. When it is, the daemon adds two rules of its own, to DOCKER-USER when Docker made it, or else to FORWARD, so sandbox traffic gets out and its replies come back. It never changes the policy itself. With ufw active, the setup command also opens the daemon's port on tailscale0, and ports 80 and 443 for the edge. Without Tailscale it opens only 80 and 443. Any other firewall in front of the server needs 80 and 443 open too.
Limits
Each sandbox can have:
| Default | Range | |
|---|---|---|
| CPUs | 1 | 1 to 32 |
| Memory | 512 MiB | 128 MiB to 64 GiB |
| Disk | 2 GiB | 64 MiB to 256 GiB |
| Lifetime | 5 minutes | up to 365 days, or no limit |
A sandbox ends when its lifetime runs out. Extend it while it runs. A sandbox with no limit (ttl: "none") runs until you delete it.
Each team also has limits on all its sandboxes together. Paused ones count.
| Limit | Default |
|---|---|
| Sandboxes at once | 10 |
| CPUs | 16 |
| Memory | 16 GiB |
| Disk | 100 GiB |
| Longest lifetime | 1 day |
The team's owners and admins change them in the team's Settings, under Sandboxes, when every sandbox server the team uses is its own. When the installation has sandbox servers that every team shares, only the installation's admin changes them. On Pyo Cloud each team has only its own servers, so its owners and admins always can. Setting Sandboxes at once to 0 turns sandboxes off for the team. Longest lifetime can be up to 365 days, or No limit, which lets the team's sandboxes run until they're deleted.
Names
Every sandbox has a name, to tell it apart from the others and find it. Give one when you create it, like checkout tests, of up to 63 letters, digits, spaces, dashes, underscores and dots. Without one, Pyo makes up a short one like quiet-river.
Names don't have to be unique, and they never address a sandbox: its id does. So renaming one breaks nothing. Rename a sandbox from its name on its page, with pyo sandbox rename, with rename_sandbox in MCP, or with a PATCH in the API. The sandboxes list searches by name or id.
Use sandboxes
An API key needs Sandboxes or Full access to use sandboxes. Sandboxes access can read, and create and use sandboxes, but change nothing else.
TypeScript SDK
Install @pyodev/sandbox:
npm install @pyodev/sandboxIt reads PYO_URL, PYO_API_KEY and PYO_TEAM from the environment, or takes them as options. It works in Node 20 and later, and in Bun.
import { Sandbox } from "@pyodev/sandbox";
// From base. Pass template to start from another one, and server to pick the server.
const sbx = await Sandbox.create({ ttl: "1h" });
// Commands
const r = await sbx.exec("node -v");
console.log(r.stdout, r.exitCode);
// Files
await sbx.files.write("/app/index.js", "console.log('hi')");
const text = await sbx.files.read("/app/index.js");
// A terminal
const pty = await sbx.pty({ cols: 120, rows: 30, onData: (b) => process.stdout.write(b) });
pty.write("ls\r");
// Ports
await sbx.spawn("npx serve -l 3000");
const url = await sbx.ports.open(3000);
await sbx.delete();- Commands:
execwaits for a command and returns its output and exit code. A command times out after 60 seconds unless you settimeoutMs, and keeps up to 8 MiB of each output.spawnstarts one and returns at once, for servers and interactive input. - Files: read, write, list, stat and remove files. Each call moves up to 64 MiB.
- Terminals:
ptyopens a terminal, with resize. - Ports:
ports.openreturns the port's URL on the edge. A private port, with{ public: false }, needs the sandbox token on each request.ports.connectopens a TCP connection to a port inside the sandbox, even with no network. - Lifetime:
extend,pause,resumeanddelete. A paused sandbox keeps its memory and files and resumes where it was. - Servers:
Sandbox.servers()lists the team's sandbox servers, each with itsruntime,firecrackerorgvisor.
The token for the sandbox server lasts an hour. The SDK gets a new one from Pyo five minutes before it runs out. To use a sandbox from a browser without an API key, your backend passes on sbx.connection() and refreshes the token for it.
The SDK builds every call from the connection's url, so the same code works on both kinds of server. The API gives the same connection:
| Field | With Tailscale | Without Tailscale |
|---|---|---|
url | The server's address on your tailnet, like https://sbx-1.tail1234.ts.net:7443 | An address on Pyo itself, under the address you reached Pyo at |
webUrl | The same as url, for the desktop and web pages | Left out |
proxied | Left out | true: the calls are proxied by Pyo |
Lists of sandboxes have url and proxied too. A server without Tailscale has no tailnetName in the list of servers. Through Pyo, the limits above apply, and a browser page on another origin can't make the calls.
The SDK also has ready-made tools for the Claude API and the Vercel AI SDK. See its README for every option.
MCP
Once your team can use a sandbox server, MCP gets sandbox tools, so an assistant can run code for you in a sandbox. Give the assistant Sandboxes or Full access.
| Tool | What it does |
|---|---|
create_sandbox | Creates a sandbox, from base unless the assistant names a template, on the server it names or one Pyo picks, and returns its id |
rename_sandbox | Gives a sandbox another name |
run_code | Runs Python, Node or Bash code and returns its output |
exec | Runs a shell command |
read_file and write_file | Read and write a file |
open_port and close_port | Serve a port at a URL, or stop serving it |
pause_sandbox | Pauses a sandbox |
delete_sandbox | Ends a sandbox and throws away its files |
These go through Pyo, so the assistant doesn't need your tailnet. See the full tool list.
CLI
The pyo CLI has pyo sandbox:
pyo sandbox create --name checkout-tests --ttl 30m
pyo sandbox exec sbx_abc123 "node -v"
pyo sandbox shell sbx_abc123
pyo sandbox cp ./app.js sbx_abc123:/app/app.js
pyo sandbox ports open sbx_abc123 3000
pyo sandbox rm sbx_abc123pyo sandbox create starts from base. Name a template to start from another one, like pyo sandbox create node-22, and pick the server with --server sandbox-1. --ttl takes a lifetime like 30m, 6h or 7d, or none to keep it until you delete it. It also has ls, get, rename, pause, resume, extend and token, and servers and templates to manage those. exec, shell and cp call the sandbox server at its connection's address. With Tailscale that's on your tailnet, so they need your tailnet. Without it they go through Pyo. See the command reference.
Dashboard
The Sandboxes page lists your sandboxes by name, with a search. A running sandbox has Terminal right in the list, and a desktop sandbox has Desktop and Browser too. The New sandbox button in the page's header opens a menu with New sandbox and Add server. New sandbox creates one, and shows the same choices as SDK code, ready to copy. Its Server field is Any server by default, and lists each server with its runtime and free memory. Its Lifetime goes from 5 minutes up to the team's longest, or No limit when the team allows it. Sandbox templates has a Use button on each template that opens New sandbox on it. A sandbox's page has its Overview with its ports, a Terminal, its Files, the Commands it ran and its Metrics.
Planned
These aren't in Pyo yet:
- Templates from a Git repository or a Dockerfile.
- Pausing a sandbox on its own when it's idle.
- Allow and deny lists for a sandbox's outgoing traffic.
- A Python SDK.
- Promote a sandbox to a service, with a domain, HTTPS and autoscaling.