Skip to main content

Sailboxes vs. E2B: CPU billing and session length

You can raise the CPU limit on Sail without paying for unused cores. Sail charges $0.015 per used vCPU-hour. E2B Hobby and Pro charge $0.0504 per configured vCPU-hour while the sandbox runs. A Sailbox has no fixed lifetime by default. E2B Pro limits each continuous session to 24 hours. Sail pricing · Sailbox lifecycle · E2B pricing and plan limits

Create the Sailbox

Install the Sail Python SDK on the machine that runs your controller. Run python -m pip install sail. Sign in with sail auth login. Create one Sailbox per session. This example saves its ID in a local file. In your application, store the ID with the agent session.

Transfer files

Replace sandbox.files.write(path, data) with sb.fs.write(path, data). Run this code from the directory that contains worker.py and job.json. The example worker reads /tmp/job.json and writes /tmp/result.json inside the Sailbox. Use the paths your worker needs.
Install the template dependencies in a Sail image. Start the worker with a command. Sail does not run the Dockerfile’s CMD or ENTRYPOINT.

Run your existing worker

Replace sandbox.commands.run() with sb.run(). Read the output from result.stdout. On Sail, check=True raises an exception if the command fails.
Each sb.run() call starts a new process. For E2B notebooks that use run_code(), keep an interpreter running if you need to preserve variables. Keep the same response format for notebook output.

Reconnect after sleep

An idle Sailbox sleeps automatically by default. Use the saved ID to find the same Sailbox. Read the result file. This operation wakes a sleeping Sailbox.
Sleep preserves files and memory. Termination deletes the Sailbox.

Check the worker output

Run your worker with the same input on E2B and on Sail. Compare the command output and the files from both runs.