Live — 4 Languages Supported

Execute Code In Milliseconds

Sandboxed JavaScript, Python, TypeScript, and Bash execution with sessions, file I/O, and resource limits. Sub-50ms cold start. Built for AI agents.

JS JavaScript
PY Python 3
TS TypeScript
$ Bash
POST /api/execute
curl -X POST https://agent-coderunner.example.com/api/execute \
  -H "Content-Type: application/json" \
  -d '{"language":"python","code":"print(sum(range(1000)))"}'

// Response (18ms)
{
  "exitCode": 0,
  "stdout": "499500",
  "duration": 18,
  "timedOut": false
}

Why Code Runner

Everything an agent needs to execute code safely in production

🔒

Sandboxed Execution

Each run is isolated with CPU, memory (256MB), file size, and process count limits. No access to the host system. Safe for untrusted code.

Sub-50ms Cold Start

No VM spin-up. No container pull. Python runs in ~20ms, JavaScript in ~50ms, Bash in ~5ms. Faster than any serverless function.

📁

Persistent Sessions

Create sessions where files and state carry over between executions. Build multi-step data pipelines, stateful REPL loops, or iterative workflows.

Configurable Timeouts

Set per-execution timeouts up to 30 seconds. Infinite loops are killed automatically. CPU time limits prevent resource abuse.

📥

stdin & File I/O

Pass stdin data and upload files to the sandbox. Read output files back from session sandboxes. Full input/output support.

📊

Execution History

Every execution is stored with stdout, stderr, exit code, duration, and metadata. Retrieve any past execution by ID for debugging.

How It Works

Three API calls from zero to running code

1

Get API Key

POST /api/keys — instant, no signup. 50 free executions included.

2

Send Code

POST /api/execute with language and code. Results in milliseconds.

3

Get Results

stdout, stderr, exit code, duration. Full execution metadata.

Resource Limits

Safe defaults that prevent abuse without limiting real work

30s
Max Timeout
256MB
Memory Limit
512KB
Max Output
100KB
Max Code Size
10MB
Max File Size
64
Max Processes

Live API Demo

Real API calls, real results — try each language

agent-coderunner API
# Execute Python
curl -X POST https://agent-coderunner.example.com/api/execute \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{
    "language": "python",
    "code": "import math\nfor i in range(10):\n    print(f\"{i}! = {math.factorial(i)}\")",
    "timeout": 10000
  }'
Response (18ms)
{
  "id": "exec-a1b2c3",
  "exitCode": 0,
  "stdout": "0! = 1\n1! = 1\n2! = 2\n3! = 6\n4! = 24\n5! = 120\n6! = 720\n7! = 5040\n8! = 40320\n9! = 362880",
  "duration": 18,
  "timedOut": false
}
# Execute JavaScript
curl -X POST https://agent-coderunner.example.com/api/execute \
  -H "Content-Type: application/json" \
  -d '{
    "language": "javascript",
    "code": "const fib = n => n <= 1 ? n : fib(n-1) + fib(n-2);\nfor (let i = 0; i < 12; i++) console.log(`fib(${i}) = ${fib(i)}`);"
  }'
Response (47ms)
{
  "exitCode": 0,
  "stdout": "fib(0) = 0\nfib(1) = 1\nfib(2) = 1\nfib(3) = 2\n...\nfib(11) = 89",
  "duration": 47,
  "timedOut": false
}
# Execute Bash
curl -X POST https://agent-coderunner.example.com/api/execute \
  -H "Content-Type: application/json" \
  -d '{
    "language": "bash",
    "code": "echo \"System Info:\"\nuname -a\necho \"\nDisk:\"\ndf -h / | tail -1"
  }'
Response (6ms)
{
  "exitCode": 0,
  "stdout": "System Info:\nLinux vps 6.8.0 ...\n\nDisk:\n/dev/vda1  78G  42G  33G  57% /",
  "duration": 6,
  "timedOut": false
}
# 1. Create a persistent session
curl -X POST .../api/sessions -d '{"language":"python"}'
# -> {"sessionId": "sess-abc123", "language": "Python 3.12"}

# 2. Write data in session
curl -X POST .../api/sessions/sess-abc123/execute \
  -d '{"code": "import json\ndata = {\"users\": 100}\njson.dump(data, open(\"state.json\",\"w\"))\nprint(\"Saved\")"}'
# -> stdout: "Saved"

# 3. Read data in same session (files persist!)
curl -X POST .../api/sessions/sess-abc123/execute \
  -d '{"code": "import json\ndata = json.load(open(\"state.json\"))\nprint(f\"Users: {data[\\\"users\\\"]}\")"}'
# -> stdout: "Users: 100"

Integrate in Minutes

Drop-in code for your agent or application

Integration Examples
# Get an API key (instant, no signup)
curl -X POST https://agent-coderunner.example.com/api/keys

# Execute Python code
curl -X POST https://agent-coderunner.example.com/api/execute \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{
    "language": "python",
    "code": "import json\ndata = [i**2 for i in range(20)]\nprint(json.dumps(data))",
    "timeout": 5000
  }'

# Create a session for multi-step work
curl -X POST https://agent-coderunner.example.com/api/sessions \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"language": "python"}'
import requests

API = "https://agent-coderunner.example.com"

# Get API key (instant, no signup)
key = requests.post(f"{API}/api/keys").json()["apiKey"]
headers = {
    "Authorization": f"Bearer {key}",
    "Content-Type": "application/json"
}

# Execute code
result = requests.post(f"{API}/api/execute", headers=headers, json={
    "language": "python",
    "code": "print(sum(range(100)))",
    "timeout": 5000
}).json()

print(result["stdout"])  # "4950"
print(result["duration"])  # 18 (ms)

# Use sessions for stateful work
session = requests.post(f"{API}/api/sessions",
    headers=headers, json={"language": "python"}).json()

requests.post(f"{API}/api/sessions/{session['sessionId']}/execute",
    headers=headers, json={"code": "x = 42"})

r2 = requests.post(f"{API}/api/sessions/{session['sessionId']}/execute",
    headers=headers, json={"code": "print(x * 2)"}).json()
print(r2["stdout"])  # "84"
const API = "https://agent-coderunner.example.com";

// Get API key (instant, no signup)
const { apiKey } = await fetch(`${API}/api/keys`, {
  method: "POST"
}).then(r => r.json());

// Execute code
const result = await fetch(`${API}/api/execute`, {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    language: "javascript",
    code: `
      const squares = Array.from({length: 10}, (_, i) => i * i);
      console.log(JSON.stringify(squares));
    `,
    timeout: 5000
  })
}).then(r => r.json());

console.log(result.stdout);    // "[0,1,4,9,16,25,36,49,64,81]"
console.log(result.duration);  // 47 (ms)

Pricing

Start free. Scale with USDC when you need more.

Free

$0 /forever
  • 50 executions included
  • 10 requests/minute
  • All 4 languages
  • Sessions & file I/O
  • 30s max timeout
  • No credit card needed
Get Free Key

Pro

500 credits/USDC
  • 500 executions per USDC
  • 120 requests/minute
  • All 4 languages
  • Sessions & file I/O
  • 30s max timeout
  • Pay with USDC on Base
Get Started

Clawdia API Suite

Code Runner is part of a complete infrastructure for AI agents