kosa8 / Switch

Switch · from Modal

Switch from Modal Sandboxes

Checked

If you train with Prime's verifiers, its Modal runtime was removed on 2026-10-19 (see the verifiers guide). Otherwise nothing forces a move off Modal; teams add kosa8 as a second provider or an outage fallback, or for live fork and rewind. Modal Functions and GPUs stay on Modal.

01Why teams add a second provider

  • 2026-10-19: verifiers PR #2862 removed the modal and e2b runtimes; Prime is now its only built-in sandbox [2].
  • Modal memory snapshots are alpha, expire after 7 days and terminate the source sandbox [3]. kosa8 forks a running sandbox and keeps it running.
  • Modal has GPUs and kosa8 Cloud does not. If your sandboxes need GPUs, keep them on Modal.

02Change one import

Modal

python
import modal
# reads MODAL_TOKEN_ID / MODAL_TOKEN_SECRET

app = modal.App.lookup("my-app", create_if_missing=True)
sb = modal.Sandbox.create(app=app, image=modal.Image.debian_slim(), timeout=300)
p = sb.exec("python3", "-c", "print(6 * 7)")
print(p.stdout.read().strip())
sb.terminate()

kosa8

python
import kosa8.compat.modal as modal
# reads KOSA8_API_KEY

app = modal.App.lookup("my-app", create_if_missing=True)
sb = modal.Sandbox.create(app=app, image=modal.Image.debian_slim(), timeout=300)
p = sb.exec("python3", "-c", "print(6 * 7)")
print(p.stdout.read().strip())     # 42
sb.terminate()

Install with pip install kosa8 and set KOSA8_API_KEY. Image.debian_slim() becomes python:3.12-slim; with no image, the sandbox starts kosa8's python template.

03What was tested

  • The shim mirrors modal.Sandbox and the pieces sandbox code touches, from the modal Python SDK 1.6.4 reference checked 2026-11-21. It is covered by kosa8-py's unit tests and the docs snippet runs against production.
  • Modal's own test suite has not been run against it. The .aio variants, Functions and Volumes are not mirrored.

04What behaves differently

Modalkosa8 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
sandbox.exec outputStreamsStreams as it prints and is not held to 90 s
Entrypoint outputStreamsstdout is polled about once a second; stderr arrives when it ends
ImagesBuilt in code (pip_install, run_commands...)Not built: use a registry image, or set a sandbox up once and start from snapshot_filesystem()
PortsTunnelssandbox.kosa8.previews.create(port) returns a signed https link
SnapshotsFilesystem, directory, and memory (alpha)snapshot_filesystem() keeps memory and disk; the source keeps running
API keyMODAL_TOKEN_ID / MODAL_TOKEN_SECRETKOSA8_API_KEY

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.

05Calls that raise Unsupported

Read from compat/modal.py:

CallWhat kosa8 says to use instead
Image build steps: pip_install, uv_pip_install, apt_install, run_commands, dockerfile_commands, add_local_*, workdir, envkosa8 does not build images: build and push one, then Image.from_registry('registry/name:tag'); or set a sandbox up once and reuse it with snapshot_filesystem()
Image.from_dockerfileBuild and push the image yourself, then Image.from_registry
Image.from_registry(secret=..., add_python=..., setup_dockerfile_commands=...)A public image, or a kosa8 template built from your private one
Sandbox.create(gpu=...)kosa8 GPU hosts are not in the Cloud API yet
Sandbox.create(volumes=..., network_file_systems=...), reload_volumesKeep data in /workspace, or snapshot_filesystem() and start from it
Sandbox.create(encrypted_ports, h2_ports, unencrypted_ports, custom_domain), tunnels, create_connect_tokensandbox.kosa8.previews.create(port) gives an https URL (a signed link)
Sandbox.create(pty=...), exec(pty=True)sandbox.kosa8.terminal() gives a wss:// terminal URL
Sandbox.create(outbound_*_allowlist, cidr_allowlist, proxy, _experimental_outbound_policy)sandbox.kosa8.set_egress(allow=[...]) after create; HTTPS_PROXY in env
Sandbox.create(region=[several])One region, e.g. region='us'
Sandbox.create(runtime=..., cloud=..., readiness_probe=...)Leave it out (kosa8 sandboxes are microVMs); poll exec until your check passes
StreamWriter.write / write_eof / drain (stdin)Write the input to a file in /workspace
Secret.from_dotenv; exec(secrets=[Secret.from_name(...)])Secret.from_dict(dotenv_values('.env')); name org secrets at create
filesystem.watch, Sandbox.watchPoll filesystem.list_files(path)
Sandbox.logssandbox.kosa8.logs()
snapshot_directory, mount_image, unmount_imagesnapshot_filesystem() of the whole sandbox; start from it
Sandbox.open / ls / mkdir / rmsandbox.filesystem.read_text, list_files, make_directory, remove
Functions, Volumes, the .aio variantsNot mirrored; kosa8 has its own functions

06Switching 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.

07What 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.

08Sources, 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. Modal: Pricing
  2. verifiers PR #2862
  3. Modal docs: Sandbox snapshots
  4. kosa8 docs: Migrate from Modal

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.