Sandboxed JavaScript, Python, TypeScript, and Bash execution with sessions, file I/O, and resource limits. Sub-50ms cold start. Built for AI agents.
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 }
Everything an agent needs to execute code safely in production
Each run is isolated with CPU, memory (256MB), file size, and process count limits. No access to the host system. Safe for untrusted code.
No VM spin-up. No container pull. Python runs in ~20ms, JavaScript in ~50ms, Bash in ~5ms. Faster than any serverless function.
Create sessions where files and state carry over between executions. Build multi-step data pipelines, stateful REPL loops, or iterative workflows.
Set per-execution timeouts up to 30 seconds. Infinite loops are killed automatically. CPU time limits prevent resource abuse.
Pass stdin data and upload files to the sandbox. Read output files back from session sandboxes. Full input/output support.
Every execution is stored with stdout, stderr, exit code, duration, and metadata. Retrieve any past execution by ID for debugging.
Three API calls from zero to running code
POST /api/keys — instant, no signup. 50 free executions included.
POST /api/execute with language and code. Results in milliseconds.
stdout, stderr, exit code, duration. Full execution metadata.
Safe defaults that prevent abuse without limiting real work
Real API calls, real results — try each language
# 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 }'
{
"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)}`);" }'
{
"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" }'
{
"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"
Drop-in code for your agent or application
# 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)
Start free. Scale with USDC when you need more.
Code Runner is part of a complete infrastructure for AI agents
Turn any URL into clean markdown, HTML, or structured text
Programmatic web search with structured JSON results
Capture any URL as PNG with custom viewports
One API for GPT-4, Claude, Gemini, Llama, and more
KV store + vector search for persistent agent state