Skip to main content
You need a Styne API key; create one on the dashboard (API keys).
1

Switch

Set these in the process that runs your code:
The SDK then calls https://api.styne.ai and serves ports on https://<port>-<sandbox id>.styne.ai, the domain the create answer names. Your code stays as it is.E2B_SANDBOX_URL sends the commands and file calls of every sandbox over one kept-open connection, so the first command of a new sandbox answers as fast as the second.On e2b versions before 2.48 (some agent frameworks pin e2b 2.31), also set E2B_VALIDATE_API_KEY=false: those versions check that a key starts with e2b_.To set them from Python instead:
The with block kills the sandbox when it ends. The SDK sends its own timeout of 300 seconds on create; pass timeout= to change it.
2

Check

Run this once. It uses the calls most programs use; every line has to print.
3

Adapt what differs

4

Cut over

Run both providers side by side behind a switch in your own config (the variables from step 1), send a small share of traffic to Styne, compare exit codes and timings, and move the rest. Nothing in your sandbox code needs a second code path.

What is the same

  • Sandbox.create, Sandbox.connect, kill, pause and resume, get_info, set_timeout and list.
  • commands.run with streaming output, exit codes (a non-zero exit raises CommandExitException), background processes and stdin.
  • The filesystem calls: read, write, list, stat, make directory, move and remove.
  • get_host(port) for a port URL.
  • The user a call names: commands.run(..., user="user") runs as E2B’s user account (home /home/user, sudo without a password), user="root" as root, and files written for user belong to it. A call that names no user runs as root in /home/user. The e2b 1.x SDKs name user on every call, as on E2B.
  • A sandbox made with secure: false (the e2b 1.x SDKs’ default) takes envd and code-interpreter calls without the access token, as on E2B; a create from a 2.x SDK always needs it.
  • A sandbox that is gone answers 404: kill() returns False and connect() raises NotFoundException, so cleanup code can run twice. Plain HTTP callers get 410 with the reason and time the sandbox ended (see errors).
  • The SDK’s v2 calls: GET /v2/sandboxes, POST /v2/sandboxes and POST /v2/sandboxes/{id}/connect answer like the routes without /v2.
  • Logs, metrics, templates and volumes: get_metrics (GET /sandboxes/{id}/metrics) and GET /sandboxes/metrics?sandbox_ids=, GET /sandboxes/{id}/logs and GET /v2/sandboxes/{id}/logs, the team metrics (GET /teams/{teamID}/metrics and /metrics/max, where the team id is the key’s account id; one sample taken when asked), Template.build with its builds, status, logs and tags (GET /templates/{id}/builds, /tags, /tags/count, /tags/exists, /tags/groups and /tags/{tag}/assignments), GET /v2/templates/{id}, and volumes (GET and POST /volumes, GET and DELETE /volumes/{id}, volumeMounts on create).
  • The E2B Code Interpreter SDK (e2b-code-interpreter): Sandbox.create() starts its default code-interpreter-v1, and run_code runs Python in a context that keeps its variables between calls, with stdout, stderr, the cell’s result (text, HTML, images and matplotlib figures) and errors with their traceback. create_code_context, list_code_contexts, restart_code_context and remove_code_context work; language="bash" and "js" run each cell as a process of its own.
  • Public port URLs: https://<port>-<id>.<domain> opens without a token, as on E2B. Create with network.allowPublicTraffic: false to make every port need the trafficAccessToken.
  • The error shape: a code, a message and a request id.
Conformance is measured against the official e2b package, not against a hand-written client.

What is different

  • Templates are the Styne templates. base is the general Linux image (Debian 12) with Python 3 as python and python3 (pip install works), Node 22, git, curl, wget, sudo, libatomic and the accounts user and daytona (see sandboxes); code-interpreter-v1 starts base, and a template name that does not exist, such as node, answers 404. GET /templates/{id} returns one template.
  • A path that is not a route of this API answers 404 with error_code unknown_route and a message naming the path and this page, so the SDK raises with the reason.
  • A fork is a Styne operation; see fork. The SDK has no call for it: use HTTP.
  • A browser session is a Styne product of its own; see browsers.
  • A create field the API does not know is accepted and ignored. region and class are Styne fields, not E2B ones: an unknown region or a class that is not served is refused with 422, and the SDKs choose the region with the styne.region metadata key (see Regions).
  • Extra on Styne, outside the SDKs: fork, snapshots, pause tiers, public ports and signed URLs, reached with plain HTTP, the CLI, or curl.

Errors and limits

The SDK raises its own exceptions for the API’s answers: 401 AuthenticationException, 404 NotFoundException, 503 ServiceBusyException (not a subclass of SandboxException in Python, catch it by name). Branch on error_code in the JSON body, not on the message: see errors. The limits of each plan are on limits; GET /v1/run/usage shows what your account is held to.