BlockRun
Marketplace

PARTNER

Modal Sandbox

Secure Code Runtime For AI Agents

Run untrusted Python in isolated sandboxes, keep multi-step workflows alive, and pay per run with x402. Modal gives agents a clean execution environment without making them manage containers, API keys, or infrastructure.

4 endpoints live on Base
Isolated execution
Pay per run
Persistent sandbox session
No account required
PUBLIC BETA

Current public access is tuned for safe agent workflows: Python 3.11 on Base, up to 1 vCPU, 1 GiB RAM, and 5 minute sandbox lifetime. Custom images, GPU sandboxes, and setup-time provisioning are coming later.

Why Agents Reach For It

The value is not raw compute horsepower. It is giving an agent a safe, disposable, stateful place to run code when localhost execution would be risky or operationally messy.

Isolated Runtime
Run code outside your app server in an isolated sandbox session instead of on the host machine.
Stepwise Execution
Create once, execute multiple commands, inspect outputs between steps, and keep workflow state inside the sandbox.
Debuggable Workflows
Capture stdout, stderr, exit codes, and status checks so agents can reason about what happened and what to do next.
Wallet-Native Access
Pay per run with x402 on Base. No accounts, API keys, or infrastructure setup required for the caller.

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 agents an execution layer they can call on demand, reason over, and tear down when the job is done.

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 Verification

$0.012 per test

Install dependencies in a clean sandbox, run checks or tests, and inspect failures without polluting the host environment.

sandbox/createmanaged Python 3.11 sandbox$0.01
sandbox/execpip install + pytest$0.001
sandbox/terminatecleanup$0.001

Data Processing & Automation

$0.012+ per job

Transform files, parse data, run scripts, or execute lightweight automation steps in a sandbox the agent can inspect and control.

sandbox/createup to 1 vCPU / 1 GiB / 5 min$0.01
sandbox/execrun processing step$0.001
sandbox/terminaterelease sandbox$0.001

Multi-Step Agent Workflows

$0.013+ per workflow

Create a persistent sandbox session, execute multiple commands across steps, inspect outputs between turns, and terminate when done.

sandbox/createcreate session$0.01
sandbox/execstep 1$0.001
sandbox/execstep 2$0.001
sandbox/terminatedone$0.001

Pricing

Per-request pricing. You pay for the sandbox session and each lifecycle operation.

sandbox/create
$0.01
per sandbox
Managed Python 3.11 sandbox, up to 1 vCPU, 1 GiB RAM, 5 minute lifetime
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 and payment requirements.

EndpointMethodPriceDescription
/api/v1/modal/sandbox/createPOST$0.010Create a managed Python 3.11 sandbox with bounded CPU, memory, and lifetime limits.
/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 session, run code, and clean up:

# Base (USDC on Base)
curl -X POST https://blockrun.ai/api/v1/modal/sandbox/create \
  -H "Content-Type: application/json" \
  -d '{"image": "python:3.11", "timeout": 300}'
# Returns: 402 with price ($0.0100) and Base USDC payment instructions

# Paid request — create 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", ...}

# 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}

# 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 agent code safely

Fund your wallet with USDC on Base and start giving your agent a safe place to execute code. No registration, no API keys required.