BlockRun
AI tools / Secure Runtime API

Run untrusted agent code in a sandbox you pay for per session

Create an isolated runtime, execute code in it and tear it down, billed per sandbox and per operation in USDC. No cluster to run and no platform subscription.

Code sandbox API: an isolated runtime for untrusted agent code

Four requests: create a sandbox on a managed Python image — CPU by default, or a GPU type on request — then exec a command inside it and read stdout, stderr and the exit code, poll its status, and terminate it. Create carries the sandbox price; each of the other three is a small per-operation price.

A short-lived CPU sandbox is the flat rate on the card. A GPU type prices the create call above it by tier, and a lifetime beyond the flat-rate window bills it by the hour for the whole lifetime you requested, up front, with no refund on early terminate — the parameter table below carries the exact window, caps and GPU types the route enforces, and the 402 quotes the exact figure before anything runs.

How to call the sandbox API — create, exec, status, terminate

One endpoint, priced in dollars before it runs and settled in USDC. No API key and no account — the request pays for itself.

POST /api/v1/modal/sandbox/create
Host: blockrun.ai

Request parameters

fieldtype
imagestring
timeoutnumber
cpunumber
memorynumber
gpustring

* required

Sandboxed code execution for AI agents: from an MCP host or the SDK

In Claude Code, Claude Desktop, Cursor, Windsurf, Cline and any other MCP host, this is the blockrun_modal tool of the BlockRun MCP server — the agent calls it like any other tool and the result comes back in the conversation. In OpenClaw, Codex and Hermes, ClawRouter exposes the same catalog. In your own code, the Python and TypeScript SDKs wrap the endpoint above with types; any HTTP client works too. Every harness, with its setup →

No account and no API key stand between an agent and the first call: the request is quoted in dollars and the agent's client pays it. A team that prefers keys gets one, with a monthly invoice.

Code sandbox API vs E2B, Modal direct and Daytona

E2B, Daytona and Modal each sell secure code execution for agents behind an account: a key, a monthly plan or a prepaid balance, and a usage bill at the end. Modal is the runtime behind this page — the same managed images, the same isolation — reached without the account.

Four requests: create a sandbox on a managed Python image, CPU by default or a GPU type on request; exec a command inside it and read stdout, stderr and the exit code; poll its status; terminate it. Create carries the sandbox price, and each of the other three is a small per-operation price, so an agent that runs one snippet pays for one sandbox and a few operations, not a month.

The one thing to know before creating: lifetime is priced up front. A short-lived CPU sandbox is the flat rate on the card; a longer lifetime or a GPU type prices the create call above it, and there is no refund on early terminate. The parameter table above carries the exact window, caps and GPU types the route enforces.

Code sandbox API questions: isolation, GPUs, lifetime, languages, pricing

What is a code sandbox API for AI agents?

An endpoint that creates an isolated runtime, runs commands inside it and tears it down — so model-written code, which is untrusted input, executes away from your own environment and is billed for the session it used.

Why run agent code in a sandbox instead of locally?

Model-written code is untrusted input. A sandbox keeps it off your machine and your network, gives it a clean image every time, and is torn down explicitly so nothing is left running to be billed for.

How is the code sandbox API priced?

One price to create a sandbox — flat for a short-lived CPU sandbox, higher for a GPU type or a longer lifetime — and a small price per exec, status and terminate call, all quoted before anything runs.

Can I get a GPU sandbox through the API?

Yes. Create takes a GPU type from the list in the parameter table above; the create call is priced by GPU tier, up front, for the lifetime you request.

How long does a sandbox live?

For the lifetime you request at create, up to the cap in the parameter table, and it is terminated explicitly. Lifetime is billed up front with no refund on early terminate.

What languages can run in the sandbox?

The managed image is Python, and exec runs any shell command inside it — so anything installable into that image runs, with stdout, stderr and the exit code returned. The parameter table above lists the images the route accepts.

Does the sandbox persist files between sessions?

No. Each sandbox is a fresh image for its lifetime; anything the code produces has to be read out through exec before terminate.

Code sandbox API vs E2B, Daytona or Modal direct?

All three sell isolated execution behind an account, a key and a plan or balance. This is Modal's runtime reached per request with no account: an agent creates a sandbox, runs its code and pays for that session alone.

Can an AI agent create a sandbox without an API key?

Yes. The create request pays for itself, so an agent with a funded balance provisions its own runtime with no signup and no key.

Two ways to run this

Get an API key

Sign in, get a key, and call the same endpoints with usage billed to your account. For teams that want one invoice instead of one wallet.

Get an API key 

Or let your agent pay per call, in USDC

No account, no API key. Three steps, and the last one is the request this page is about.

  1. 01
    Point your agent at BlockRun

    Install ClawRouter, or add the BlockRun MCP server to Claude Code, Cursor, Codex or OpenClaw. Any OpenAI-compatible client works too — change the base URL, nothing else.

    curl -fsSL https://blockrun.ai/ClawRouter-update | bash
  2. 02
    Fund a wallet with USDC

    Send USDC to a wallet on Base or Solana. There is no account to create and no API key to issue: the wallet is the account, and it pays per call.

  3. 03
    Call Code Sandbox API

    The first call returns HTTP 402 with the exact price, your agent signs it, and the answer comes back. Payment settles on-chain; nothing is charged if the call fails.

    POST /api/v1/modal/sandbox/create
    Host: blockrun.ai

How a call is paid: the request is answered with its exact dollar price (HTTP 402), the client pays that amount from its balance and resends, the call runs. No invoice afterwards on this door; an API key and a monthly invoice on the other. The mechanism →