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 limitsCreate the Sailbox
Install the Sail Python SDK on the machine that runs your controller. Runpython -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
Replacesandbox.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.
CMD or ENTRYPOINT.
Run your existing worker
Replacesandbox.commands.run() with sb.run(). Read the output from result.stdout. On Sail, check=True raises an exception if the command fails.
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.