kosa8 docs Dashboard
esc
↑ ↓ move↵ openRuns in your browser; nothing you type is sent anywhere.

Guides

Migrate from Modal

Change import modal to import kosa8.compat.modal as modal, set KOSA8_API_KEY, and your modal.Sandbox code runs on kosa8.

# Before: import modal
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.returncode, p.stdout.read().strip())     # 0 42
sb.terminate()

How it maps#

Modalkosa8 Cloud
Sandbox.create(...)Create. image from Image.from_registry or debian_slim, timeout the ttl, idle_timeout sleep after idle, cpu and memory a size, Secret.from_name org secrets
sandbox.exec(*args)A streamed exec, returned while it runs; stdout iterates lines as they print
terminateDelete
snapshot_filesystemA snapshot, usable as image=
filesystem.*, set_tagsThe files API, labels

What is different#

  • sandbox.exec output streams as it prints and is not held to 90 s. An entrypoint's stdout is polled about once a second and its stderr arrives when it ends.
  • With the Python shim (0.7.0 and later) the sandbox is persistent: installed packages, files outside /workspace and background processes last between commands (KOSA8_SHIM_PERSISTENT=0 turns that off; a plan with no persistent sandboxes left gets a plain one, where only /workspace lasts). Each command is still a new process, so cd and export do not carry.
  • Image builds (pip_install, run_commands), GPUs, volumes and stdin raise kosa8.compat.Unsupported; encrypted_ports and sandbox.tunnels() map to kosa8 previews (HTTPS only, no raw TCP). Install once and keep a snapshot instead.
  • Modal Functions are not mirrored; kosa8 has its own functions. Only the synchronous Sandbox API (Modal 1.6.4) is mirrored, not .aio.

Something wrong or missing? Write to contact@kosa8.com.

The kosa8 weekly

Agent security news, one industry deep-dive and a hands-on challenge, every Monday. Unsubscribe in one click.

© 2026 kosa8 · kosa8.com · Zero Trust cybersecurity infrastructure for AI agents · Local models served by llamay · Agent gateway: MAQPNA