PARTNER
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.
Capabilities
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 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 Testing
$0.012 per testInstall and test packages in a clean environment. Verify compatibility, run test suites, check for security issues — all in isolation.
sandbox/createwith setup_commands$0.01sandbox/execpip install + pytest$0.001sandbox/terminatecleanup$0.001GPU Compute Jobs
$0.012+ per jobSpin 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.01sandbox/execrun ML pipeline$0.001sandbox/terminaterelease GPU$0.001Multi-Step Workflows
$0.013+ per workflowCreate a persistent sandbox, execute multiple commands across steps, check status between operations, and terminate when done.
sandbox/createlong timeout$0.01sandbox/execstep 1$0.001sandbox/execstep 2$0.001sandbox/terminatedone$0.001Pricing
Per-request pricing. No subscriptions, no monthly minimums.
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.
| Endpoint | Method | Price | Description |
|---|---|---|---|
/api/v1/modal/sandbox/create | POST | $0.010 | Create a sandboxed compute environment. Supports custom images, CPU/memory/GPU configuration, and setup commands. |
/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 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.