PARTNER
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.
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.
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 sessionAgent creates a sandbox, executes user-provided code safely, captures output, and terminates. Perfect for chat-based code assistants.
sandbox/createpython:3.11 image$0.01sandbox/execrun user code$0.001sandbox/terminatecleanup$0.001Package Verification
$0.012 per testInstall dependencies in a clean sandbox, run checks or tests, and inspect failures without polluting the host environment.
sandbox/createmanaged Python 3.11 sandbox$0.01sandbox/execpip install + pytest$0.001sandbox/terminatecleanup$0.001Data Processing & Automation
$0.012+ per jobTransform 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.01sandbox/execrun processing step$0.001sandbox/terminaterelease sandbox$0.001Multi-Step Agent Workflows
$0.013+ per workflowCreate a persistent sandbox session, execute multiple commands across steps, inspect outputs between turns, and terminate when done.
sandbox/createcreate session$0.01sandbox/execstep 1$0.001sandbox/execstep 2$0.001sandbox/terminatedone$0.001Pricing
Per-request pricing. You pay for the sandbox session and each lifecycle operation.
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.
| Endpoint | Method | Price | Description |
|---|---|---|---|
/api/v1/modal/sandbox/create | POST | $0.010 | Create a managed Python 3.11 sandbox with bounded CPU, memory, and lifetime limits. |
/api/v1/modal/sandbox/exec | POST | $0.001 | Execute a command inside a running sandbox. Returns stdout, stderr, and exit code. |
/api/v1/modal/sandbox/status | POST | $0.001 | Check the status of a sandbox (running or terminated). |
/api/v1/modal/sandbox/terminate | POST | $0.001 | Terminate 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.