Migrate from E2B
Two ways, and neither rewrites your code. Both run on ordinary kosa8 sandboxes, so fork, checkpoints and the dashboard work on them too.
Option 1: keep the E2B SDK, change three variables#
kosa8 Cloud answers the E2B API at /e2b. Point the E2B SDK there with a kosa8 key:
export E2B_API_KEY=k8c_live_… # a kosa8 Cloud key export E2B_API_URL=https://api.kosa8.com/e2b export E2B_SANDBOX_URL=https://api.kosa8.com/e2b/envd
from e2b import Sandbox sbx = Sandbox.create("python", timeout=300) sbx.files.write("hello.py", "print('hello from kosa8')\n") # /workspace/hello.py print(sbx.commands.run("python3 hello.py", cwd="/workspace").stdout) sbx.kill()
Tested with the E2B Python SDK 2.64.0 on 2026-11-22. E2B plans to drop E2B_API_URL in its next
major version, so pin e2b<3.
Option 2: change one import#
The kosa8 Python SDK has an E2B-shaped Sandbox that talks to kosa8 directly:
# Before: from e2b import Sandbox from kosa8.compat.e2b import Sandbox # reads KOSA8_API_KEY sbx = Sandbox.create("python", timeout=300) # deleted after 300 s sbx.files.write("/workspace/hello.py", "print('hello from kosa8')\n") r = sbx.commands.run("python3 hello.py", cwd="/workspace") print(r.stdout.strip()) # hello from kosa8 sbx.kill()
kosa8.compat.e2b_code_interpreter does the same for e2b_code_interpreter. It mirrors
the synchronous API of e2b 2.64.0; AsyncSandbox is not mirrored.
What is different#
- Option 1: the template
baseis kosa8's own, Alpine with no Python. Ask for"python","node"or an image. Option 2: with no template, or"base", the shim starts kosa8'spythontemplate. - Each command runs in a fresh container on the sandbox's disk; only
/workspacepersists, socd, exported variables and background daemons do not carry between commands. A plain buffered command runs at most 90 s (output callbacks or atimeoutover 90 s make it a streamed exec), and commands take no stdin. - Option 2 reads
KOSA8_API_KEY, orE2B_API_KEYwhen it holds a kosa8 key; a real E2B key is refused. - Option 2 (the Python shim, 0.7.0 and later) makes a persistent sandbox: installed packages, files outside
/workspaceand background processes last between commands (KOSA8_SHIM_PERSISTENT=0turns that off). The note above on/workspaceis Option 1's behaviour. - Relative file paths are under
/workspace, but a command starts in/unless you passcwd. timeoutbecomes the sandbox'sttl_s(60 s at least).pauseis kosa8 sleep: memory and disk kept.- Anything kosa8 cannot do raises
kosa8.compat.Unsupportedrather than silently doing something else.
The full mapping is in framework integrations.
Something wrong or missing? Write to contact@kosa8.com.