Switch from Modal
| Modal | Runtime |
|---|---|
modal.Sandbox.create(app=app, image=image) |
POST /v2/sandboxes, with image or snapshot |
sb.exec("python", "-c", code) |
POST /v2/sandboxes/{id}:exec, with wait false to read output as it comes |
sb.open(path, "w") |
PUT /v2/sandboxes/{id}/files |
sb.tunnels() |
POST /v2/sandboxes/{id}/previews |
sb.snapshot_filesystem() |
POST /v2/sandboxes/{id}:snapshot |
sb.terminate() |
DELETE /v2/sandboxes/{id} |
Pythonfrom withruntime.generated import Runtimeruntime = Runtime()sandbox = runtime.sandboxes.create()try: result = runtime.sandboxes.exec(sandbox.id, cmd=["python3", "-c", "import sys; print(sys.version_info[0])"]) print(result.stdout) # 3 assert result.stdout.strip() == "3", resultfinally: runtime.sandboxes.delete(sandbox.id)Runtime bills the CPU a sandbox uses, $0.03 per busy vCPU-hour, and a paused sandbox pays only for storage, $0.18 per GB-month.
Give this to your agent#
Paste this into your coding agent:
Read https://withruntime.com/docs/switch-from-modal.md. Replace every Modal Sandbox call in this project with its Runtime call, on a branch, run the project's tests and its real job on Runtime, and fix what fails. Never delete the Modal account or its tokens.
This page as Markdown: https://withruntime.com/docs/switch-from-modal.md
Try it on your own work.Signing up takes no card. Your first sandbox asks for one, and the trial starts then. Or paste the setup prompt into your agent.