kosa8 / Switch

Switch · from E2B

Switch from E2B

Checked

There is no deadline forcing anyone off E2B. The reason to read this page is to add a second provider: an outage fallback, more room when you hit a concurrency limit, or a sandbox you can fork and rewind. Two routes, neither rewrites your code, and switching back is one line.

01Why teams add a second provider

No forced trigger here. E2B's pricing page, read on 2026-11-23, lists up to 10 concurrently running sandboxes and 1-hour sessions on Hobby, and 100 and 24 hours on Pro [1]. Teams add a second provider when they reach those limits, or to have somewhere to send work when one provider has an incident.

02Route 1: change one import

Before and after, the same program:

E2B

python
from e2b import Sandbox
# reads E2B_API_KEY

sbx = Sandbox.create("base", timeout=300)
sbx.files.write("hello.py", "print('hi')\n")
r = sbx.commands.run("python3 hello.py",
                     cwd="/home/user")
print(r.stdout)
sbx.kill()

kosa8

python
from kosa8.compat.e2b import Sandbox
# reads KOSA8_API_KEY (an E2B key is refused)

sbx = Sandbox.create("base", timeout=300)   # "base" starts kosa8's python template
sbx.files.write("hello.py", "print('hi')\n")   # /workspace/hello.py
r = sbx.commands.run("python3 hello.py",
                     cwd="/workspace")
print(r.stdout)
sbx.kill()

Install with pip install kosa8 and set KOSA8_API_KEY. e2b_code_interpreter works the same way: from kosa8.compat.e2b_code_interpreter import Sandbox. The code-interpreter sandbox is persistent (one long-lived container), because the interpreter keeps its Python process between cells; it counts against your plan's persistent-sandbox limit.

03Route 2: keep the E2B SDK, change three variables

kosa8 Cloud answers the E2B API at /e2b. The stock E2B SDK reaches it with a kosa8 key:

bash
pip install 'e2b<3'
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
python your_agent.py                       # unchanged code

E2B has said it will drop E2B_API_URL in its next major version, so pin e2b<3. On this route the template base is kosa8's own base: Alpine, with no Python. Ask for python, node or an image instead.

04What was tested

  • Route 2 with the E2B Python SDK 2.64.0, on 2026-11-22.
  • Route 1 mirrors the synchronous API of e2b 2.64.0 and e2b-code-interpreter 2.11.10, from E2B's public reference checked 2026-11-21. It is covered by kosa8-py's own unit tests; E2B's own test suite has not been run against it yet.
  • The E2B JavaScript SDK has an E2B shim in @kosa8/sdk; it was not re-tested for this page.

05What behaves differently

E2Bkosa8 shim today
State between commandsOne machine lives across commands: cd, exported env and background daemons surviveEach command runs in a fresh container on the sandbox's disk; only /workspace persists. Relative paths are put under /workspace
Long plain commandsRun until their timeoutA buffered command (no output callbacks, no timeout over 90 s) runs at most 90 s. With callbacks or a longer timeout it is streamed and not held to 90 s
stdinSupportedNot supported: kosa8 commands take no stdin. Write the input to a file in /workspace and read it
Background command outputStreamedPolled about once a second; stdout and stderr arrive together
Default templatePython includedThe shim starts kosa8's python template (E2B's base maps to it). Route 2 starts kosa8's base: Alpine, no Python
Preview URLget_host(port) returns a host name such as PORT-ID.e2b.appget_host raises Unsupported; sandbox.kosa8.previews.create(port)['url'] returns a signed private link
Network changes on a running sandboxupdate_networkRaises Unsupported; use sandbox.kosa8.set_egress(...)
API keyE2B_API_KEYThe import shim reads KOSA8_API_KEY (or api_key='k8c_live_...'); an E2B key is refused. Route 2 reads E2B_API_KEY holding a kosa8 key
timeoutSandbox lifetimeThe sandbox's lifetime (ttl_s), 60 s at least
pausePause with memorykosa8 sleep: memory and disk kept; the next command wakes it

This table reflects kosa8-py 0.6.0 (src/kosa8/compat) as of 2026-11-23. Shim fidelity is being improved; when a row changes, this page changes with it.

06Calls that raise Unsupported

A call kosa8 cannot do raises kosa8.compat.Unsupported, which names the method and the kosa8 alternative. The shim never pretends a call worked. The list, read from compat/e2b.py:

CallWhat kosa8 says to use instead
Commands.run(stdin=True), send_stdin, close_stdin, stream_inputWrite the input to a file in /workspace
Commands.run(user=...)Commands run as the image's user; switch user inside the command (su, sudo)
Sandbox.pty, CommandHandle.wait(on_pty=...)sandbox.kosa8.terminal() gives a wss:// URL for an interactive terminal
Sandbox.get_host(port)sandbox.kosa8.previews.create(port)['url']: a signed private link (public=True for an open one)
Sandbox.update_networksandbox.kosa8.set_egress(internet=..., allow=[...], deny=[...])
Sandbox.create(network=...)allow_internet_access=False, or sandbox.kosa8.set_egress(...)
Sandbox.create(mcp=...), get_mcp_url, get_mcp_tokenRun your MCP server with commands.run(..., background=True) and expose its port with a preview
Sandbox.create(volume_mounts=...)Keep data in /workspace, or snapshot the sandbox
Sandbox.create(iam=...)Org secrets: Kosa8Cloud().sandboxes.create(secrets=[...])
Sandbox.create(cpu_count=...)Kosa8Cloud().sandboxes.create(size='2x4')
Sandbox.create(idempotency_key=...)Look the sandbox up by name
Sandbox.create(lifecycle={'auto_resume': True})Leave it out: a kosa8 sandbox wakes for the next command by itself
Filesystem.watch_dirPoll files.list(path)
Filesystem.write(metadata=...)Keep metadata in a sidecar file
Commands.listKeep the handle or pid that run(background=True) returned
Sandbox.upload_urlsandbox.kosa8.files.link(path, method='PUT') (a PUT of the raw bytes, not a multipart POST)
Sandbox.get_metricssandbox.kosa8.metrics() (kosa8's own fields)
Sandbox.git (deprecated by E2B)commands.run('git ...') in an image with git
Sandbox.pause (filesystem only), create_snapshot(mode=...)kosa8 pause and snapshots always keep memory and disk
Sandbox.connect(on_resume=...) other than 'restore'on_resume='restore'
run_code in a language other than Python; run_code(envs=...)Python only; other languages through commands.run (node -e ...)
create_code_context(cwd=...) or a non-Python languageos.chdir(...) in the first cell; Python contexts only
AsyncSandboxNot mirrored; use the synchronous Sandbox

07Switching back is one line

The shim is one import. To go back, change the import back and set your old key. Nothing else in your code was rewritten, so there is nothing to undo. Running both at once is fine: keep the original SDK for the calls kosa8 raises Unsupported on, and use kosa8 for the rest.

08What it costs

Start free: the Starter tier needs no card, with $10 of one-time usage, 2 sandboxes running, up to 2 vCPU, 60-minute sessions, for 14 days. Paid plans from $29 a month include sandbox-hours; usage above the plan is metered per second up to a spend cap you set, on by default at $50. Pricing.

09Sources, checked on 2026-11-23

Facts about another product come from that vendor's own pages, read on 2026-11-23. Products change quickly: check the current pages before you decide, and tell us if something here is out of date and we will fix it.

  1. E2B: Pricing
  2. E2B docs: Sandbox persistence
  3. kosa8 docs: Migrate from E2B
  4. kosa8-py compat shims (source)

Run your own code on it first.

No card for the Starter tier. Paid plans from $29 a month, with a spend cap on by default.