What It Costs to Run Claude Code or Codex in a Cloud Sandbox

What It Costs to Run Claude Code or Codex in a Cloud Sandbox

Author
Daniel Botha
Daniel Botha
Writer at Fly.io
Published

A four-hour Claude Code or Codex session in a cloud sandbox costs about $0.23 on Fly.io Sprites and $0.48 to $0.95 on Cloudflare Sandbox, Vercel Sandbox, E2B, Daytona and Modal Sandboxes, because a coding agent spends most of its session waiting on model calls and only some providers stop billing while it waits.

You want the agent off your laptop. It might be running with permission prompts turned off, working a ticket while you sit in a meeting, or one of five agents on five branches at once. A cloud sandbox gives each of them its own machine, and the bill turns on a detail most pricing pages bury: whether you pay for the CPU and memory the sandbox reserved, or only for what the agent actually used.

For a coding agent those two numbers are far apart. Claude Code sends a prompt and waits for tokens to stream back, and the builds and test runs between turns are short bursts inside long waits. Every figure below is the sandbox alone; the model usage that drives the agent is a separate bill.


How Much Does It Cost to Run Claude Code in a Cloud Sandbox?

A Claude Code session costs about $0.06 an hour on Fly.io Sprites and $0.12 to $0.24 an hour on the other five providers, for a sandbox reserved at 2 vCPU and 4 GiB that averages 30% CPU and 1.5 GB of resident memory. The 30% figure is generous to the agent. Vercel’s own worked examples for its sandbox assume 10% CPU utilization, “reflecting time spent waiting for LLM calls”.[1]

Provider, 2 vCPU / 4 GiB reserved, 30% CPU busy, 1.5 GB used, 5 GB disk 1-hour session 4-hour session 8-hour session
E2B $0.17 $0.66 $1.32
Daytona $0.17 $0.66 $1.32
Modal Sandboxes $0.24 $0.95 $1.90
Vercel Sandbox $0.16 $0.65 $1.29
Cloudflare Sandbox (standard-3, 2 vCPU / 8 GiB) $0.12 $0.48 $0.95
Fly.io Sprites $0.06 $0.23 $0.47

Our arithmetic on published rates, not a figure any vendor quotes. Rates from each provider’s own pricing page: [1] [2] [3] [4] [5] [6] [7]. Checked 2026-10-05. Plan fees, credits and included allowances excluded. Cloudflare has no 2 vCPU / 4 GiB shape, so the nearest one carries the memory and disk it provisions.

Fly.io publishes this exact session as its own example: four hours that burst to 8 CPUs and 8 GB but average 30% of 2 CPUs and 1.5 GB, itemized as 2.4 CPU-hours for $0.09, 6 GB-hours of memory for $0.13 and a cent of storage, for $0.23.[7] That is a quarter of Modal’s price and under half of the next cheapest. Each provider’s cost is a fixed hourly rate for this workload, so the order holds at every session length.


What Is the Cheapest Sandbox for Claude Code?

Fly.io Sprites are the cheapest of these six sandboxes for Claude Code, because a Sprite bills the CPU time and memory the agent actually used, and a coding agent mostly waits. The other five bill some or all of what the sandbox reserved. The full six-provider rate table is in AI sandbox pricing; here is how each billing model lands on this one workload.

Reserved CPU and memory: E2B, Daytona and Modal

E2B bills running sandboxes “per second for provisioned CPU and RAM”.[2] Daytona charges for the resources reserved while a sandbox is started.[8] Modal charges whichever is higher, the request or actual usage,[9] and prices sandbox CPU per physical core, which it counts as 2 vCPU.[4] On all three, a sandbox waiting on a model response costs what it would cost compiling.

Active CPU, provisioned memory: Vercel and Cloudflare

Vercel does not count time spent waiting on I/O, including AI model calls, toward Active CPU, but bills memory on what is provisioned, at 2 GB per vCPU.[1] Cloudflare splits the bill the same way, charging CPU on active use and memory and disk on the instance type, in 10 ms increments.[5] Its shapes are fixed, and the nearest one to 2 vCPU / 4 GiB is standard-3 with 8 GiB,[6] so the agent pays for 6.5 GiB it never touches. Cloudflare’s Sandbox SDK adds Workers requests and a Durable Object per sandbox on top.[10]

Used CPU and used memory: Fly.io Sprites

A Sprite bills $0.0385 per CPU-hour of CPU time used and $0.021875 per GB-hour of memory used.[7] Thirty percent of 2 CPUs over four hours is 2.4 CPU-hours, and 1.5 GB for four hours is 6 GB-hours. The headroom the agent never filled costs nothing.

When the ranking changes

Usage billing wins when there is idle time to leave off the bill. A sandbox that runs a compiler flat out for four hours has none. In our arithmetic, four hours at 100% of 2 CPUs with 4 GB in use comes to $0.66 on E2B and Daytona against $0.67 on a Sprite, and at 8 GB in use Cloudflare’s $0.88 beats a Sprite’s $1.02. A coding agent spends only its build minutes there; the waits around them decide the bill.


How Much Does a Coding Agent Cost per Month?

One developer running Claude Code in a cloud sandbox four hours every working day pays about $5.28 a month for the sandbox on Fly.io Sprites, and $10.49 to $20.94 on the other five, before any plan fee.

Provider, 22 working days, workspace kept between sessions 4 hours a day 8 hours a day
E2B $14.57 $29.15
Daytona $14.57 $29.15
Modal Sandboxes $20.94 $41.87
Vercel Sandbox $14.22 $28.44
Cloudflare Sandbox (standard-3) $10.49 $20.98
Fly.io Sprites $5.28 $10.49

Our arithmetic on published rates, not a figure any vendor quotes, from [1] [2] [3] [4] [5] [7]. Checked 2026-10-05. Same session as above. Between sessions a Sprite’s 5 GB sits in cold storage, E2B is paused and Daytona stopped; other providers’ persistence storage and plan fees excluded.

Keeping the workspace means day two starts with the repo cloned and dependencies installed. A Sprite sleeps when activity stops, compute billing stops, and the disk persists, per the Sprite lifecycle docs. E2B stops billing a paused sandbox,[11] and Daytona bills a stopped one for its reserved disk only.[8]

Plan fees can outweigh the usage. E2B’s Pro plan, which lifts the one-hour Hobby session cap to 24 hours, costs $150 a month plus usage,[2] about ten times this developer’s sandbox bill. Modal’s Team plan costs $250 a month,[4] Cloudflare Containers need the $5 Workers Paid plan,[5] and Vercel bills Pro usage against a $20 monthly credit first.[1]


What a Sandbox per Ticket Costs a Team

A team that gives every ticket its own Claude Code sandbox pays about $49 a month on Fly.io Sprites for 1,100 tickets, against $98 to $196 on the other providers. Each ticket gets a fresh sandbox, the agent works the branch, and the sandbox is destroyed once the pull request is open. The trade against one that persists is in ephemeral vs persistent sandboxes.

Provider, 10 developers x 5 tickets a day x 22 days, 45 minutes per sandbox 1,100 sandboxes a month 100 agents for one hour
E2B $136.62 $16.56
Daytona $136.62 $16.56
Modal Sandboxes $196.28 $23.79
Vercel Sandbox $133.32 $16.16
Cloudflare Sandbox (standard-3) $98.37 $11.92
Fly.io Sprites $48.95 $5.93

Our arithmetic on published rates, not a figure any vendor quotes, from [1] [2] [3] [4] [5] [7]. Checked 2026-10-05. Same 2 vCPU / 4 GiB session, destroyed after each ticket. Vercel includes its creation charge. Plan fees excluded.

At this scale concurrency bites before price: fifty tickets in flight is fifty sandboxes. E2B’s Hobby plan allows 20 concurrently running sandboxes and Pro allows 100,[2] and Vercel’s Hobby plan allows 10 against 10,000 on Pro.[1] Vercel’s $0.60 per million creations adds under a tenth of a cent.


YOLO Mode and Long-Running Tasks: Session Limits and What They Cost

Running Claude Code with --dangerously-skip-permissions belongs in a sandbox, and Anthropic’s documentation says so directly: always run those sessions inside a container, a VM or the sandbox runtime, so that file tools, MCP servers and hooks sit inside the boundary as well.[12] With no prompts, whoever wrote the README, the issue or a dependency’s install script can steer the agent, and what it runs reaches your SSH keys, your cloud credentials and every other repo on your laptop. A cloud sandbox holds none of those. Codex’s danger-full-access mode is the same switch, and OpenAI reserves it for isolated environments.[13]

Unattended runs are also long runs, and session caps decide whether one finishes. E2B caps continuous runtime at one hour on Hobby and 24 hours on Pro, counted as time without pausing.[11] Vercel caps a session at 45 minutes on Hobby and 24 hours on Pro, resetting when a sandbox stops and resumes.[1] An eight-hour overnight run costs $0.47 on a Sprite, which has no session cap, against $0.95 to $1.90 elsewhere. The isolation side is covered in agent sandboxes.


Can Claude Code Be Sandboxed Locally Instead?

Yes. Claude Code ships a built-in sandbox that the operating system enforces on its shell commands, using Seatbelt on macOS and bubblewrap on Linux, with no infrastructure bill.[14] File tools, MCP servers and hooks run outside it. Anthropic’s own comparison climbs from there. The sandbox runtime wraps the whole Claude Code process, a dev container moves the entire environment into Docker, and a virtual machine, including a microVM such as Firecracker, gives the agent its own kernel.[12] Anthropic’s example dev container ships a default-deny firewall, which suits skip-permissions runs at your desk. What a separate kernel buys is explained in Firecracker VM.

Codex sandboxes the same way locally: by default it edits and runs commands inside the project and asks before reaching further.[13] Its cloud mode gives each task a workspace that keeps working while your computer sleeps.[15]

A local sandbox costs nothing extra and ties the agent to the machine. The cloud earns its cents per session when the laptop has to close, when five agents would fight over one machine’s cores, or when the repository is untrusted, where Anthropic’s guidance is a dedicated VM.[12]


Claude Code Sandbox Cost on Fly.io

On Fly.io, a coding agent runs in a Sprite: a Firecracker microVM with its own kernel and 100 GB of ext4, with Claude Code and Codex already installed on new Sprites. CPU is metered on time actually used and memory on what is actually resident, so the minutes Claude Code spends waiting on the model cost a fraction of what a reserved sandbox charges. When activity stops the Sprite sleeps and compute billing stops; the next command wakes it with its files intact. With no session cap, an overnight YOLO run finishes on its own schedule, and a checkpoint taken first puts the environment back if the agent wrecks it. The Sprites quickstart gets one running.

An agent that never sleeps, one holding a socket open all day or serving what it built, runs on Fly Machines instead. Machines are billed per second, and a shared-cpu-2x Machine with 2 GB running continuously costs $13.39 a month.[16] Sprites and Machines share the same Firecracker substrate, so code an agent builds in a Sprite runs on a Machine with no rewrite. Any configuration can be priced before you commit at fly.io/calculator.


Frequently Asked Questions

What’s the cheapest way to run Claude Code in a sandbox?

The cheapest cloud sandbox for Claude Code is a Fly.io Sprite, which bills only the CPU time and memory the agent actually uses. A four-hour session averaging 30% of 2 CPUs and 1.5 GB comes to about $0.23, against $0.48 to $0.95 on Cloudflare, Vercel, E2B, Daytona and Modal at their published rates. Claude Code’s built-in local sandbox adds no infrastructure bill, but it keeps the agent on your own machine.

Does a sandbox cost money while Claude Code waits on the model?

Yes, on most providers. E2B, Daytona and Modal bill reserved CPU and memory for every second the sandbox runs, waiting or not, and Vercel and Cloudflare stop billing CPU during waits but keep billing provisioned memory. A Fly.io Sprite bills only the CPU time and memory actually used, and when activity stops it sleeps and compute billing stops.

How much does it cost to run 100 coding agents for an hour?

About $5.93 on Fly.io Sprites, for 100 sandboxes at 2 vCPU and 4 GiB averaging 30% CPU and 1.5 GB of memory. The same hour costs $11.92 on Cloudflare Sandbox, $16.16 on Vercel Sandbox, $16.56 on E2B and Daytona, and $23.79 on Modal Sandboxes at published rates, before plan fees.

Is a cloud sandbox cheaper than a VPS for Claude Code?

Yes, for an agent that works a few hours a day, because a sandbox that sleeps bills for the hours it works and an always-on server bills for all of them. Four hours every working day costs about $5.28 a month in a Fly.io Sprite, against $13.39 a month for a shared-cpu-2x Fly Machine with 2 GB running continuously. An agent that has to stay up around the clock belongs on that Machine.

Should I run Claude Code in Docker or in a cloud sandbox?

Run it in a cloud sandbox when the agent works unattended, runs in parallel or touches a repository you do not trust, and in a local container for everyday work at your desk. Anthropic’s preconfigured dev container blocks unapproved network traffic, which makes it a reasonable local home for skip-permissions runs. In the cloud, a Fly.io Sprite runs the same session for about $0.06 an hour and keeps working after the laptop closes.

What is the best sandbox for Codex?

A Fly.io Sprite, for the same reason as Claude Code: Codex spends most of a session waiting on the model, and a Sprite bills only the CPU and memory actually used. Codex comes installed on new Sprites. Its own full-access mode, which drops filesystem and network restrictions, is meant for isolated environments, and a Sprite is one.


Sources

  1. ^ Vercel, “Vercel Sandbox pricing and quotas”. vercel.com/docs/sandbox/pricing. Checked 2026-10-05.
  2. ^ E2B, “Pricing”. e2b.dev/pricing. Checked 2026-10-05.
  3. ^ Daytona, “Pricing”. www.daytona.io/pricing. Checked 2026-10-05.
  4. ^ Modal, “Pricing: Pay per second for GPUs and CPUs”. modal.com/pricing. Checked 2026-10-05.
  5. ^ Cloudflare, “Pricing (Containers)”. developers.cloudflare.com/containers/platform/pricing. Checked 2026-10-05.
  6. ^ Cloudflare, “Limits and instance types (Containers)”. developers.cloudflare.com/containers/platform/limits. Checked 2026-10-05.
  7. ^ Fly.io, “Sprites: Linux computers for agents”. fly.io/sprites. Checked 2026-10-05.
  8. ^ Daytona, “Billing”. www.daytona.io/docs/en/billing. Checked 2026-10-05.
  9. ^ Modal, “Configuring CPU, memory, and disk”. modal.com/docs/guide/resources. Checked 2026-10-05.
  10. ^ Cloudflare, “Pricing (Sandbox SDK)”. developers.cloudflare.com/sandbox/sdk/platform/pricing. Checked 2026-10-05.
  11. ^ E2B, “Billing & limits”. docs.e2b.dev/billing. Checked 2026-10-05.
  12. ^ Anthropic, “Choose a sandbox environment”. code.claude.com/docs/en/sandbox-environments. Checked 2026-10-05.
  13. ^ OpenAI, “Sandbox (Codex)”. learn.chatgpt.com/docs/sandboxing. Checked 2026-10-05.
  14. ^ Anthropic, “Configure the sandboxed Bash tool”. code.claude.com/docs/en/sandboxing. Checked 2026-10-05.
  15. ^ OpenAI, “Codex cloud”. learn.chatgpt.com/docs/cloud. Checked 2026-10-05.
  16. ^ Fly.io, “Fly.io Resource Pricing”. docs.fly.io/about/pricing. Checked 2026-10-05.

Run your agent in a Sprite

Pay for the CPU and memory your coding agent actually uses, not what it reserved.

Sign up