All Data Sources

PARTNER

Modal Sandbox

Isolated Code Execution for AI Agents

Modal is a serverless GPU compute platform. Through BlockRun, AI agents can create isolated sandbox environments, execute code, install packages, and run computations — all paid per request with USDC via x402. No Modal account required.

4 endpoints live on Base

Capabilities

Create Sandbox
Spin up isolated containers with custom images, CPU/memory allocation, and optional GPU. Supports Python, Node, Go, Rust — any Docker image.
Execute Code
Run commands inside a sandbox and get stdout, stderr, and exit code back. Install packages, run scripts, process data.
Monitor Status
Check if a sandbox is still running or has terminated. Poll status to track long-running jobs.
Clean Termination
Terminate sandboxes when done to release resources. Automatic timeout cleanup as a safety net.

What AI Agents Use It For

AI agents need safe, isolated environments to execute code without risking the host system. Modal Sandbox on BlockRun gives any agent on-demand compute — no provisioning, no accounts.

Code Interpreter

$0.012 per session

Agent creates a sandbox, executes user-provided code safely, captures output, and terminates. Perfect for chat-based code assistants.

sandbox/createpython:3.11 image$0.01
sandbox/execrun user code$0.001
sandbox/terminatecleanup$0.001

Package Testing

$0.012 per test

Install and test packages in a clean environment. Verify compatibility, run test suites, check for security issues — all in isolation.

sandbox/createwith setup_commands$0.01
sandbox/execpip install + pytest$0.001
sandbox/terminatecleanup$0.001

GPU Compute Jobs

$0.012+ per job

Spin up a sandbox with GPU (T4, A10G, A100, H100), run ML inference or data processing, and shut down. Pay only for what you use.

sandbox/creategpu: H100$0.01
sandbox/execrun ML pipeline$0.001
sandbox/terminaterelease GPU$0.001

Multi-Step Workflows

$0.013+ per workflow

Create a persistent sandbox, execute multiple commands across steps, check status between operations, and terminate when done.

sandbox/createlong timeout$0.01
sandbox/execstep 1$0.001
sandbox/execstep 2$0.001
sandbox/terminatedone$0.001

Pricing

Per-request pricing. No subscriptions, no monthly minimums.

sandbox/create
$0.01
per sandbox
Includes container boot, image pull, and setup commands
exec / status / terminate
$0.001
per request
Lightweight operations on existing sandboxes

API Reference

Base (USDC): https://blockrun.ai/api/v1/modal/

All endpoints accept POST with a JSON body. Send without a payment header to get a 402 with the exact price.

EndpointMethodPriceDescription
/api/v1/modal/sandbox/createPOST$0.010Create a sandboxed compute environment. Supports custom images, CPU/memory/GPU configuration, and setup commands.
/api/v1/modal/sandbox/execPOST$0.001Execute a command inside a running sandbox. Returns stdout, stderr, and exit code.
/api/v1/modal/sandbox/statusPOST$0.001Check the status of a sandbox (running or terminated).
/api/v1/modal/sandbox/terminatePOST$0.001Terminate a running sandbox and release its resources.

Quick Start

Create a sandbox and run code in a single flow:

# 1. Create a sandbox ($0.01)
curl -X POST https://blockrun.ai/api/v1/modal/sandbox/create \
  -H "Content-Type: application/json" \
  -H "x-payment: <x402_payment_token>" \
  -d '{"image": "python:3.11", "timeout": 300}'
# Returns: {"sandbox_id": "sb-xxx", "status": "running", ...}

# 2. Execute code ($0.001)
curl -X POST https://blockrun.ai/api/v1/modal/sandbox/exec \
  -H "Content-Type: application/json" \
  -H "x-payment: <x402_payment_token>" \
  -d '{"sandbox_id": "sb-xxx", "command": ["python", "-c", "print(2+2)"]}'
# Returns: {"stdout": "4\n", "stderr": "", "returncode": 0}

# 3. Terminate ($0.001)
curl -X POST https://blockrun.ai/api/v1/modal/sandbox/terminate \
  -H "Content-Type: application/json" \
  -H "x-payment: <x402_payment_token>" \
  -d '{"sandbox_id": "sb-xxx"}'
# Returns: {"sandbox_id": "sb-xxx", "status": "terminated"}

Use the BlockRun Python SDK or TypeScript SDK to handle x402 payment automatically.

Start running code with Modal

Fund your wallet with USDC on Base and start executing code immediately. No registration, no API keys required.