# Migrate from Daytona

Change `from daytona import …` to `from kosa8.compat.daytona import …`, set `KOSA8_API_KEY`, and run.

**Python**

```
# Before: from daytona import Daytona, CreateSandboxFromSnapshotParams
from kosa8.compat.daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()                              # reads KOSA8_API_KEY
sandbox = daytona.create(CreateSandboxFromSnapshotParams(snapshot="python"))
r = sandbox.process.code_run("print(6 * 7)")
print(r.exit_code, r.result.strip())             # 0 42
daytona.delete(sandbox)
```

## How it maps

| Daytona | kosa8 Cloud |
|---|---|
| `Daytona().create(params)` | Create. `snapshot` is a kosa8 template (or a `snap_…` snapshot), `image` an OCI image, `resources` a size, `auto_stop_interval` sleep after idle |
| `get` / `list` / `delete` | Get (by id or name), list, delete |
| `start` / `stop` / `pause` | Wake, sleep, sleep |
| `sandbox.process.exec` / `code_run` | Exec (`cwd` relative to `/workspace`) |
| `sandbox.fs.*` | The files API |
| `sandbox.fork` | Fork |
| `sandbox.create_snapshot(name)` | A kosa8 snapshot, memory and disk included |

## What is different

- The key is a kosa8 key (`KOSA8_API_KEY`, `DAYTONA_API_KEY` when it holds a kosa8 key, or `DaytonaConfig(api_key="k8c_live_…")`). A real Daytona key is not used, and an `api_url` that is not kosa8's is refused, so your key never goes elsewhere.

- Daytona snapshots are images you build; kosa8 snapshots are saved sandboxes. Building an image (`daytona.snapshot.create`) raises `kosa8.compat.Unsupported`.

- 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 between commands, session commands included. Commands take no stdin.

- A buffered exec runs at most 90 s; session commands and a `timeout` over 90 s are streamed and not held to it. Only the synchronous API (Daytona 2.1.0) is mirrored, not `AsyncDaytona`.

---
Source: https://docs.kosa8.com/migrate/daytona/
