NewSandboxAPI V4.0 · MCP-native

The code execution backend for AI agents

Run untrusted code in gVisor-isolated sandboxes with one API call. Sessions, package install, streaming and MCP are built in, so you never operate sandbox infrastructure.

  • 500 free requests per RapidAPI subscription period
  • Runs
POST /v1/execute
Response sample output
Total: 245
Live sandbox. Edit the code and press Run. Open the full Playground
  • gVisor kernel isolationEvery execution runs in its own sandbox
  • Network off by defaultOpt-in managed public HTTPS on paid plans
  • MCP-nativeWorks with Claude Code, Codex, Cursor and VS Code
  • 4 integration modesSync, streaming, async and sessions

Your first execution in three steps

No SDK to install and no sandbox to provision. It is one HTTPS request from any language.

  1. Get an API keySubscribe to the $0 Basic plan on RapidAPI.
  2. POST your codeSend a language and source to /v1/execute.
  3. Read the resultGet stdout, stderr, exit code, time and memory usage back as JSON.
Get a free API key Read the docs
curl https://sandboxapi.p.rapidapi.com/v1/execute \
  -H "Content-Type: application/json" \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
  -d '{"language":"python3","code":"print(2 + 2)"}'
Response · 200 OK
{
  "status": "completed",
  "stdout": "4\n",
  "stderr": "",
  "exit_code": 0,
  "execution_time_ms": 45
}

Six things that make SandboxAPI different

Every other code-execution API stops at "send code, get output." We ship the full toolkit AI agents and modern developer tooling actually need.

Stateful sessions

Persistent sandboxes retain files and installed packages across calls. Interpreter globals reset between calls, so agents store state on disk.

# Files persist → POST "open('x.txt','w').write('42')" → POST "print(open('x.txt').read())" → stdout: "42"

Package install

Stable pip and npm install direct requested artifacts from a curated cache behind the managed install proxy. List every required package explicitly; transitive resolution is planned.

# Controlled cached install path manager: "pip" packages: ["pandas", "numpy"]

Streaming output

Server-Sent Events deliver live stdout/stderr as code runs. No polling, no buffering. Render to a terminal in real time.

# SSE events → stdout: "Step 1" → stdout: "Step 2" → result: exit 0

Async polling

Enabled in production: submit a long-running job, get a job ID, and poll until it finishes. Ultra supports 300s and Mega 600s here; an unavailable async queue returns 503 instead of falling back to sync.

# Fire-and-poll async: true job_id: "job_abc" GET /v1/executions/job_abc

8 modern languages

Python 3.12, Node 22, TypeScript 5.6.3, Go 1.22, Java 21, GCC 12 for C/C++, and Bash 5.2. Focused coverage for the languages agents and coding platforms use most.

# Current runtimes "python3" // 3.12 "javascript" // Node 22 "typescript" // 5.6.3 via esbuild "go" // 1.22

gVisor security

gVisor mediates application syscalls through a user-space kernel, adding an isolation boundary beyond the container runtime. Production requires the runsc runtime.

# Isolation stack code → Docker → gVisor (runsc) → host kernel

Four ways to integrate

Same API, four execution patterns. Pick the one that matches your workflow.

  • Sync for one-shot execution and AI tool calls
  • Streaming for live output and long-running code
  • Async for long jobs and polling workflows
  • Sessions for iterative agents that persist files and packages
Read the full API docs

Sync. Best for one-shot execution and AI tool calls

curl -X POST .../v1/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"language":"python3","code":"print(2+2)"}'

Connect Claude Code, Codex, Cursor, and more

The hosted Streamable HTTP adapter exposes four stateless tools and routes every invocation through RapidAPI. Sessions, package install, managed HTTPS, streaming, and async remain REST-only.

Use your RapidAPI subscription

Claude Code, Codex, Cursor, VS Code, and Antigravity can connect over Streamable HTTP using your RapidAPI key as a Bearer token. Pick your client's setup in the integration guide.

  • execute_code, execute_batch, list_languages
  • get_capabilities
  • One tool invocation maps to one RapidAPI request
MCP integration guide
~/.codex/config.toml
# Codex: ~/.codex/config.toml
# Provide the key through the Codex environment.
[mcp_servers.sandboxapi]
url = "https://mcp.sandboxapi.dev/mcp"
bearer_token_env_var = "SANDBOXAPI_RAPIDAPI_KEY"
tool_timeout_sec = 180

See it in action

Real-world examples you can run right now. Click any example to try it in the Playground.

Predictable pricing, four plans

All plans include 8 languages, gVisor isolation, stdin, batch execution, and streaming. Pro is the recommended first paid step; Ultra is built for serious workflows, and Mega is the high-volume RapidAPI plan.

Basic
$0/mo
500 requests / RapidAPI subscription period
  • Safe free code execution
  • 8 languages
  • 30s max timeout
  • Up to 10 accepted items per batch
  • No outbound network
Start free
Ultra
$49/mo
50,000 requests / RapidAPI subscription period
  • Everything in Pro
  • 150s sync/session · 300s async
  • Up to 100 accepted items per batch
  • 5 concurrent sessions
  • Curated popular-package cache
  • Optional exact/wildcard domain rules (max 32)
Subscribe
Mega
New
$149/mo
200,000 requests / RapidAPI subscription period
  • Everything in Ultra
  • 150s sync/session · 600s async · up to 200 accepted items/batch
  • 60 requests/minute
  • 8 concurrent sessions · 30m idle max
  • Curated package cache · 300 installs/account/hour
  • Opt-in HTTPS with optional domain rules
  • Planned: customer audit logs; static egress IP is deployment-dependent
Choose Mega
Limits, billing and network access in detail
  • Network is off by default; Basic and playground traffic cannot enable it.
  • Paid API requests can opt in to managed public HTTPS with network.enabled, while Ultra and Mega can optionally set allowed_domains.
  • This is an explicit HTTPS_PROXY path: clients must honor or be configured for that proxy, and raw public sockets are unavailable.
  • One endpoint call is one RapidAPI request; batch limits are maximum accepted items, processed through bounded workers within a 150-second request wall-clock budget.
  • RapidAPI's gateway maximum is 180 seconds, leaving 30 seconds for delivery and cleanup.
  • RapidAPI meters bandwidth in 1 MB units, with 10,240 MB/month currently included on every plan, then $0.001 per MB above that allowance and owns each subscription-period request allowance; SandboxAPI applies per-minute burst limits per RapidAPI subscriber identity.
  • Session caps are per-RapidAPI-account ceilings.
  • Shared service capacity is not reserved; during saturation, session creation may return HTTP 503 with Retry-After.

Questions developers ask first

How is untrusted code isolated?

gVisor mediates application syscalls through a user-space kernel, adding an isolation boundary beyond the container runtime. Each execution runs in its own sandbox with strict resource limits, and network is off by default.

Is there a free plan?

Yes. Basic is $0 and includes 500 requests per RapidAPI subscription period, all 8 languages and a 30s max timeout. You can also run code in the Playground before subscribing.

Does state persist between calls?

In a session, files and installed packages persist across calls. Interpreter globals reset between calls, so agents store state on disk. Sessions are available on Pro, Ultra and Mega.

Can my code reach the internet?

Not by default. Paid API requests can opt in to managed public HTTPS with network.enabled, and Ultra and Mega can optionally restrict it with allowed_domains. Basic and playground traffic cannot enable it.

What counts as a request?

One endpoint call is one RapidAPI request. Batch limits cap the items a single call may carry, from 10 on Basic to 200 on Mega.

Can I use it from Claude Code, Codex or Cursor?

Yes. The hosted MCP adapter exposes four stateless tools over Streamable HTTP and authenticates with your RapidAPI key. See the MCP integration guide for each client's setup.

Stop building sandbox infrastructure

Get your API key and start executing code in minutes. Basic includes 500 requests per RapidAPI subscription period.