Skip to content
Markdown

Runtime vs Cloudflare Sandbox

Runtime bills CPU by use, like Cloudflare's Sandbox SDK. It costs 53% less for an agent that mostly waits on a model.

The saving: 1,000 one-minute runs of a 2 vCPU sandbox cost $0.64 on Runtime and $1.35 on Cloudflare. At 100,000 runs a month that is $63.89 against $135.04, $71 a month saved. You need no Worker to deploy and no $5 plan to hold.

Comparing more than two? Cloudflare Sandbox alternatives ranks the other providers by the cost of the same job.

Updated

On this page

Estimated compute cost2 vCPUs · 4 GiB · 60 s a run · 20 CPU-seconds busy

53% less than Cloudflare Sandbox

1,000

Compute only, at list rates checked 25 October 2026 (Cloudflare Containers pricing). Plan fees, network, taxes and free credits are left out. The worked example below shows the arithmetic.

Where Runtime is better#

  • 65% cheaper CPU. Active CPU costs $0.025 a vCPU-hour on Runtime and $0.072 on Cloudflare. Memory is cheaper too, at $0.0075 per GiB-hour against $0.009.
  • Waiting costs storage, not compute. A Runtime sandbox left idle for 300 seconds pauses by itself and keeps its memory. It then pays $0.08 per GB (10⁹ bytes) a month until a request wakes it.
  • An uptime promise that pays itself. Paid accounts are promised 99% API uptime each month. A month below it returns 10% of that month's charges as credit. No claim is needed (Uptime Promise).
  • Memory sized to the job. Cloudflare needs at least 3 GiB per vCPU, so a 2 vCPU sandbox pays for 6 GiB. On Runtime you choose vCPUs and memory separately and pay for no more.
  • Work survives idle time. A paused Runtime sandbox wakes with its files, memory and running processes, kept while you have credit. A Cloudflare sandbox restores saved files from filesystem-only snapshots in public beta. Memory and processes restart. Snapshots expire 30 days after creation or last restore.
  • A desktop built in. Start a Linux desktop in any sandbox and drive it with clicks, keys and screenshots. Cloudflare removed its Sandbox SDK desktop in version 0.10.2, in June 2026.
  • Call it from any backend, with no platform to join. Runtime is an API with JavaScript, Python, Go, Ruby and Java SDKs, a CLI and an MCP server. Prepaid credit from $10 is the whole account. The Sandbox SDK runs inside a Worker on the Workers Paid plan, deployed with Wrangler and a local Docker build.
  • Keys the sandbox never sees. Store an API key once. The sandbox holds a placeholder. Runtime's proxy adds the value only to HTTPS requests to the hosts you name. A prompt injection has nothing to leak (security).
  • Your credit matched. Credit you add within 30 days of signing up is matched, up to $1,000 in total (welcome match).
  • Your agent sets itself up. It runs npx withruntime sandboxes run -- ..., shows you a link, and starts once you approve in the browser. No API key goes into a prompt or a config file.

Also included: a code interpreter, network allow and deny lists, custom images, volumes backed up daily, snapshots and forks with memory, private previews, metrics, webhooks, OpenTelemetry export, S3, R2 and GCS bucket mounts, MCP servers from a catalog, identity tokens for AWS and Google Cloud and free single sign-on. Paid accounts add custom domains, TCP ports, dedicated outbound addresses and WireGuard private networks. See products.

At a glance#

Cloudflare's sandboxes run on Cloudflare Containers, so their prices are the Containers prices. Cloudflare's figures come from its public pricing and documentation, checked 25 October 2026.

Runtime Cloudflare Sandbox SDK
Isolation Firecracker microVM, own kernel A container in its own VM
CPU billing $0.025 per vCPU-hour of measured CPU, with a small floor $0.072 per active vCPU-hour, metered in 10 ms steps
Memory billing $0.0075 per reserved GiB-hour $0.009 per provisioned GiB-hour
Disk Included while running; paused storage $0.08 per GB (10⁹ bytes) a month $0.000252 per provisioned GB-hour
Plan fee None; prepaid credit from $10 Workers Paid, at least $5 a month
Free start 100 free hours of a 1 GB machine in the first 30 days, no card No free tier; the plan includes 375 vCPU-minutes a month
Sizes Up to 16 vCPUs and 64 GiB paid, chosen apart Up to 4 vCPUs, 12 GiB and 20 GB; at least 3 GiB per vCPU
When idle Pause keeps files and memory; kept while you have credit Filesystem-only snapshots; processes restart
Interfaces API, CLI, MCP server, JavaScript, Python, Go, Ruby and Java SDKs A TypeScript SDK called from a Cloudflare Worker

Cost for the same job#

Take 1,000 runs of a 2 vCPU sandbox. Each run lasts 60 seconds and keeps the CPU busy for 20 CPU-seconds. This is an agent that spends most of its time waiting for a model. Runtime gets 4 GiB. Cloudflare's smallest custom 2 vCPU size has 6 GiB, because a custom size needs at least 3 GiB per vCPU. It gets 12 GB of disk, the size in Cloudflare's own example.

Runtime$0.64
CPU
1,000 × 20 s / 3,600 × $0.025
$0.14
Memory
1,000 × 60 s / 3,600 × 4 × $0.0075
$0.50
Cloudflare$1.35
CPU
1,000 × 20 s × $0.000020
$0.40
Memory
1,000 × 60 s × 6 × $0.0000025
$0.90
Disk
1,000 × 60 s × 12 × $0.00000007
$0.05
  • Saving: 53%, or $0.71 per 1,000 runs.
  • Per month: at 100,000 runs, $63.89 on Runtime against $135.04 on Cloudflare.
  • Busier work: with both CPUs busy for the whole minute, $1.33 on Runtime against $3.35 on Cloudflare, a 60% saving.
  • Smaller shapes: Cloudflare's standard-1 (half a vCPU, 4 GiB, 8 GB of disk) costs $1.03 for the same runs. Runtime's nearest shape, 1 vCPU and 4 GiB, still costs $0.64, because CPU is billed as measured.

The Cloudflare figure assumes each sandbox is destroyed when its run ends. One left alone keeps billing memory and disk until its inactivity timeout ends. Workers requests, Durable Object time, the $5 plan minimum, network, taxes and free allowances are left out of both. On Runtime, inbound traffic is free. Each account's first 100 GiB out a month is free. After that, outbound traffic costs $0.02 per GB (10⁹ bytes). See pricing for Runtime's terms.

How to switch#

Give your coding agent the one instruction in migration. It replaces the Cloudflare calls on a branch, tests them on the free usage, and tells you what you save each month. Your old code stays on the main branch until you merge.

Change the import

Runtime's SDK runs a Worker written for Cloudflare's 0.x @cloudflare/sandbox API, as this page describes from SDK version 0.18.0. The switch is the import, one config block and one secret, not literally one line. Change the package name in both lines that name it:

TypeScriptimport { getSandbox } from "withruntime/cloudflare"; // was: from "@cloudflare/sandbox"export { Sandbox } from "withruntime/cloudflare"; // was: from "@cloudflare/sandbox"

In wrangler.jsonc (or wrangler.toml), delete the containers block. The sandbox runs on Runtime, so there is no image to build and no Docker on your machine. Keep the Sandbox Durable Object binding, its migration and nodejs_compat as they are.

jsonc"containers": [  { "class_name": "Sandbox", "image": "./Dockerfile", "instance_type": "lite", "max_instances": 1 }],

Create a key at https://withruntime.com/account/keys and store it as a Worker secret, never in the config or the source:

Terminalnpx wrangler secret put RUNTIME_API_KEY

getSandbox(env.Sandbox, "my-sandbox") then reaches a Runtime sandbox kept for that name. exec, streaming, files, background processes, the code interpreter, sessions, gitCheckout and exposePort with proxyToSandbox work as Cloudflare documents them. On 18 October 2026 Cloudflare's get-started Worker, its minimal and alpine examples and the runnable 0.x examples from its docs ran unchanged under wrangler dev on Runtime sandboxes, with only those changes.

What works differently:

  • Calls Runtime has no counterpart for refuse by name, before anything happens. The message says what to use instead: backups (Runtime's snapshots), tunnels and wsConnect (the URL exposePort returns), terminals, outbound interception in a Sandbox subclass (the sandbox's network rules and secrets), and container settings such as containerTimeouts and transport.
  • Process ids are Runtime's. startProcess(cmd, { processId }) and autoCleanup refuse, and a process's pid is not reported.
  • At most 4 code contexts per sandbox. Cloudflare's container has no fixed number. A fifth createCodeContext throws and says to delete one with deleteCodeContext(). runCode without a context uses one per language.
  • Errors keep their message. Across a Durable Object call, an error arrives with its message and without its code field, on Cloudflare too. So match on the message.

Version 1.0 of @cloudflare/sandbox drops getSandbox and the Sandbox class: your own Durable Object starts the Container and runs this.ctx.container.exec([...]), and the package keeps only Files, S3Mount and DirectoryBackup. On Runtime, container.exec(["sh", "task.sh"]) is box.exec(["sh", "task.sh"]), and new Files(container).writeFile(path, data) is box.files.write(path, data).

Or port the calls

Cloudflare, inside a Worker, with the 0.x @cloudflare/sandbox API:

JavaScriptimport { getSandbox } from "@cloudflare/sandbox";export { Sandbox } from "@cloudflare/sandbox";export default {  async fetch(request, env) {    const sandbox = getSandbox(env.Sandbox, "my-sandbox");    const result = await sandbox.exec("python3 -c 'print(sum([125, 250, 375]))'");    await sandbox.destroy();    return Response.json({ stdout: result.stdout });  },};

Runtime, from any server:

TypeScriptimport { Sandbox } from "withruntime";const box = await Sandbox.create();try {  await box.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n");  console.log((await box.exec("python3 /workspace/invoice.py", { check: true })).stdout);} finally {  await box.stop();}

Calling Runtime from a Worker

If your application stays on Workers, the Worker can call Runtime itself. This needs SDK version 0.4.0 or later, and the nodejs_compat compatibility flag in your Wrangler config:

tomlcompatibility_flags = ["nodejs_compat"]

A Worker has no saved login. So create a key at https://withruntime.com/account/keys and store it as a Worker secret, never in wrangler.toml or the source:

Terminalnpx wrangler secret put RUNTIME_API_KEY

Then create, run and stop:

TypeScriptimport { Runtime } from "withruntime";type Env = { RUNTIME_API_KEY: string };export default {  async fetch(_request: Request, env: Env): Promise<Response> {    const runtime = new Runtime({ apiKey: env.RUNTIME_API_KEY });    // A backstop: the sandbox stops after 5 minutes even if this request is cut off.    const box = await runtime.sandboxes.create({      timeoutSeconds: 300,      onLeaseEnd: "stop",    });    try {      await box.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n");      const result = await box.exec("python3 /workspace/invoice.py", { check: true });      return Response.json({ stdout: result.stdout });    } finally {      await box.stop();    }  },};

Earlier SDK versions fail inside a Worker with connection_error. Without nodejs_compat, the Worker does not start. This sample is type-checked against the SDK. On 23 September 2026 it ran under wrangler dev: it created a sandbox, ran the command and stopped it.

What does not carry over:

  • The Durable Object binding. Runtime sandboxes are not part of your Worker, so the Sandbox export, its Durable Object binding and the containers entry are not needed for Runtime. Remove them only when nothing uses Cloudflare's sandboxes any more.
  • Sandboxes by name. getSandbox(env.Sandbox, "my-sandbox") becomes Sandbox.getOrCreate("my-sandbox", { client: runtime }). It returns the sandbox with that name, woken if it is paused, or creates it. Names are unique in your Runtime account, so no KV entry is needed to find it again.
  • proxyToSandbox. Cloudflare routes a sandbox's preview URLs through your Worker. Runtime serves a port from its own address instead: box.previews.create(port) returns an HTTPS URL under runtimehost.com and a token (see share a port). The Worker does not proxy it.

When Cloudflare may fit better#

  • Placement near users. A Cloudflare sandbox starts in the nearest location that has its image, across Cloudflare's network. Runtime runs in one US region.
  • Your app already lives on Workers. Sandboxes then share its account, billing and bindings. Filesystem-only snapshots can restore saved files, while R2 bucket data outlives individual instances.
  • Very large fleets. A Cloudflare account can run 1,500 vCPUs and 6 TiB of memory at the same time. A paid Runtime account runs 100 sandboxes, 200 vCPUs and 400 GiB at the same time, raised on request.

Sources#

Try it on your own work. Sign up, then paste the setup prompt into your coding agent.

Start free, no card

Was this page right?