Ted Nyman Ted Nyman

A universal API to cloud code execution sandboxes

Run code anywhere, with a single interface
A universal API to cloud code execution sandboxes

Running untrusted code in isolated environments is key to building AI agents and tools.

You need to execute code safely, in isolation, and at scale (and not on your own infrastructure). Cloud sandboxes are a great way to do this. But each cloud sandbox provider has their own API, their own quirks; and in any case, you want to be able to failover providers in case of downtime.

So we built sandboxes, a universal API for cloud code execution.

One interface, many providers

Write your code once and switch between E2B, Modal, Daytona, or Cloudflare. Let the library automatically select from what’s available, or specify the provider directly.

import asyncio
from sandboxes import Sandbox

async def main():
    async with Sandbox.create(provider="modal") as sandbox:
        # Install dependencies
        await sandbox.execute("pip install requests")

        # Run your code
        result = await sandbox.execute("python analyze.py")
        print(result.stdout)

asyncio.run(main())

Switching providers is as easy as changing the provider argument, or using the SANDBOXES_PROVIDER environment variable.

Why this matters

At Cased, our infrastructure agents need to test terraform changes, run security scans, and validate deployments in isolated environments. We were tired of writing provider-specific code for each sandbox service.

sandboxes gives you:

Start using sandboxes

Install it:

uv pip install cased-sandboxes

The README has extensive examples fo the core API, file uploads, streaming output, sandbox reuse, and more.

Powerful CLI

Don’t use Python? Use the CLI to run code from your terminal or any language runtime:

# Run a script (language auto-detected from .py extension)
sandboxes run --file script.py

# Pipe code in
echo 'console.log(80)' | sandboxes run --lang node

# Execute directly
sandboxes run "node -e 'console.log(80)'"

# Choose your provider and image
sandboxes run --file test.go --provider modal --image golang:1.21

Open source, MIT licensed

Like kit, sandboxes is free and open source. The building blocks of developer tools should be accessible to everyone.