> ## Documentation Index
> Fetch the complete documentation index at: https://docs.run.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Linux sandboxes

> Run untrusted code in run.cloud Firecracker microVM sandboxes with their own kernel, billed per second, with default sizes, CPU bursting and limits.

A sandbox is a Firecracker microVM with its own kernel, not a container. Spawn
one in well under a second, run whatever you like inside it, snapshot the
filesystem, and destroy it. You are billed per second of runtime against the
resources you reserved, plus any CPU you consume above the reservation.

Use them to:

* run untrusted or agent-generated code with a real isolation boundary;
* give a coding agent a disposable machine it can break;
* run builds and tests in parallel without contending for one CI box;
* snapshot an expensive setup step once and restore it many times.

Start with [Run a sandbox](https://docs.run.cloud/sandboxes/run-sandbox.md). For reusing a prepared
filesystem, see [Snapshots](https://docs.run.cloud/sandboxes/snapshots.md).

## Defaults and sizing

A sandbox with no resources specified reserves **0.125 vCPU and 128 MiB**, which
is enough for a shell, a small script, or an idle agent waiting for work.

CPU is a floor, not a ceiling: every sandbox auto-scales above its reservation,
so short compute spikes are fast without reserving headroom you rarely use. See
[Auto-scaling CPU](#auto-scaling-cpu) for how that bills. **Memory is a hard
limit**: a VM cannot exceed the RAM it booted with, so anything memory-hungry
must ask for more up front.

Ask for the exact resources you need with `cpu` in fractional cores and
`memory` in MiB. The maximum is **32 vCPUs and 112 GiB RAM**.

## Auto-scaling CPU

Your reserved vCPU is the billing floor and is always charged while the sandbox
runs. CPU actually consumed above the floor bills as a separate
**CPU (burst)** invoice line at the same rate as reserved CPU. Auto-scaling is
not a premium, and there is nothing to turn on. Consumption is measured per
second from the VM's cgroup. Memory is unaffected: it bills on the reservation,
which is also the VM's hard ceiling.

For example, a default 0.125 vCPU sandbox that compiles at a full 1 vCPU for
10 minutes costs about $0.0002 for the floor (75 vCPU-seconds) plus about
$0.0013 for the burst (525 vCPU-seconds), roughly \$0.0015 total. The monthly
free grant applies to burst like any other usage.

### How far CPU can burst

By default a sandbox bursts up to its reservation rounded up to whole vCPUs:
0.125 vCPU bursts to 1 vCPU, and 1.5 vCPU bursts to 2. Set `cpuLimit` (cores)
to let it go further:

```ts theme={null}
const sandbox = await cloud.sandboxes.create({ cpu: 0.25, cpuLimit: 4 });
```

This sandbox reserves a quarter of a vCPU and boots with 4 vCPUs. You pay the
quarter vCPU as the floor, plus the CPU it actually uses above that, at the
same rate. An agent that mostly waits on model calls then costs about what it
uses, and it still builds at full speed. Only the reservation counts against
your organization's reserved-CPU limit.

`cpuLimit` must not be below `cpu` and is at most 32. Set it equal to `cpu` to
turn bursting off. Burst uses spare capacity on the host, so it is fastest when
the host is quiet; when sandboxes compete for CPU, each gets a share in
proportion to its reservation.

## Limits

Sandbox count, reserved CPU, and reserved memory are limited across the whole
organization. Paused and stopped sandboxes continue to reserve capacity until
they are permanently destroyed. See [Limits](https://docs.run.cloud/limits.md) for the current defaults
and how to request an increase.

Creating a sandbox is refused with `402` when the organization is over its
effective credit ceiling or past its payment grace period. See
[Access Control and Metering](https://docs.run.cloud/billing/access-control.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.