Skip to main content
E2B uses usage-based pricing. You pay per second, only while a sandbox is running, based on the vCPU and RAM allocated to it. Paused and killed sandboxes are not billed.

The formula

The rate depends on how much compute the sandbox has allocated, not on how much it actually uses.

Current rates

These rates are shown for convenience and can change. The pricing page and its usage cost calculator are the source of truth for current prices.

Worked example

A default sandbox has 2 vCPU and 512 MiB (0.5 GiB) of RAM. Running it for 1 hour:
  • vCPU: 2 x $0.0504 = $0.1008
  • RAM: 0.5 x $0.0162 = $0.0081
  • Total: about $0.109 for the hour
The same sandbox running for 5 minutes (300 seconds) would cost roughly $0.109 x (300 / 3600) = $0.009.

Get the numbers for your own sandboxes

You need three inputs: vCPU, RAM, and running time.

vCPU and RAM of a running sandbox

getInfo() returns the sandbox’s allocated cpuCount and memoryMB. Use Sandbox.list() to get the same fields for all of your running and paused sandboxes at once.

Running time

For completed runs, set up lifecycle event webhooks. The sandbox.lifecycle.killed and sandbox.lifecycle.paused events carry an event_data.execution object with everything you need to compute cost for that run:
  • vcpu_count and memory_mb - the resources that were allocated
  • execution_time - how long the sandbox ran, in milliseconds
  • started_at - when the run began
Because these fields arrive together on the terminating event, a single delivery has both the resource allocation and the duration for one completed execution. Note that the sandbox.lifecycle.created event does not include resource allocation, so read compute off the killed and paused events (or from getInfo while the sandbox is still running).

Example: cost from a webhook

The handler below receives lifecycle deliveries, and whenever a sandbox is killed or paused it reads event_data.execution and applies the formula above to log the cost of that run.
In production, verify the e2b-signature header and deduplicate on the e2b-delivery-id header, since a delivery can be retried and arrive more than once. See Sandbox lifecycle webhooks for registration and the full payload.

Reducing your bill

No. Billing stops the moment a sandbox is paused or killed. See Do paused sandboxes count toward the concurrency limit?
Start with the default resources (2 vCPU, 512 MiB RAM) and only increase them if you need to. You set cpuCount and memoryMB when building a custom template. See Billing & limits.
In the dashboard usage tab. You can also set a spending limit on the budget page.