FREE TIER — 200 CREDITS

Code Execution API

Execute JavaScript, Python, and Bash code in secure sandboxes via a simple REST API. No server setup. Get stdout, stderr, and exit codes instantly.

Code Playground

// Click "Run Code" to see output

Features

Multiple Languages

JavaScript (Node.js 20), Python 3, and Bash. Each runs in its own isolated environment with standard libraries available.

Secure Sandboxing

Code runs in isolated containers with resource limits. CPU, memory, and time are capped. No filesystem or network access from sandbox.

Full Output

Get stdout, stderr, exit code, and execution time in milliseconds. Debug errors with complete stack traces.

10s Timeout

Default 10-second timeout prevents infinite loops. Configurable per request for longer-running computations.

AI Agent Tool

Give your LLM the ability to execute code. Perfect as a tool for CrewAI, LangChain, AutoGPT, and MCP agents.

Zero Setup

No Docker, no VMs, no language runtimes to install. Send code via API, get results back. That's it.

API Endpoint

MethodEndpointDescription
POST/api/code/runExecute code in specified language

Request body: {"language": "javascript", "code": "console.log('hello')"}

Code Examples

# Run JavaScript
curl -X POST "https://agent-gateway-kappa.vercel.app/api/code/run" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"language": "javascript", "code": "console.log(2 + 2)"}'

# Response:
{
  "stdout": "4\n",
  "stderr": "",
  "exitCode": 0,
  "executionTime": 45
}

# Run Python
curl -X POST "https://agent-gateway-kappa.vercel.app/api/code/run" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"language": "python", "code": "print(sum(range(100)))"}'
const API_KEY = 'YOUR_API_KEY';
const BASE = 'https://agent-gateway-kappa.vercel.app';

// Execute Python code
const res = await fetch(`${BASE}/api/code/run`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    language: 'python',
    code: 'import math\nprint(math.pi)'
  })
});
const { stdout, executionTime } = await res.json();
console.log(stdout); // "3.141592653589793\n"
import requests

API_KEY = "YOUR_API_KEY"
BASE = "https://agent-gateway-kappa.vercel.app"

# Execute JavaScript code
r = requests.post(
    f"{BASE}/api/code/run",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    },
    json={"language": "javascript", "code": "console.log(Array.from({length:5},(_,i)=>i*i))"}
)
result = r.json()
print(result["stdout"])  # [0, 1, 4, 9, 16]

Use Cases

AI Agent Tool

Give your LLM code execution capabilities. Let it write and run code to solve math, data processing, and validation tasks.

Online Playgrounds

Build interactive code editors for tutorials, documentation, or educational platforms. No backend infrastructure needed.

Automated Testing

Run test suites, validate outputs, and check code correctness in CI/CD pipelines without managing test environments.

Data Processing

Run one-off data transformation scripts. Parse CSV, calculate statistics, or transform JSON without spinning up servers.

Frequently Asked Questions

Is the code execution API free?
Yes. 200 free credits on signup. Each code execution costs 2 credits. No credit card, no email, no signup form required.
Which programming languages are supported?
JavaScript (Node.js 20), Python 3, and Bash. Each runs in an isolated sandbox with standard libraries available.
Is it safe and sandboxed?
Yes. Code runs in isolated environments with CPU, memory, and time limits. No filesystem or network access from within the sandbox. Each execution gets a fresh environment.
Can AI agents use this?
Absolutely. This is ideal as a tool for AI agents (CrewAI, LangChain, AutoGPT, MCP). Give your LLM the ability to write and execute code to solve problems, validate outputs, and process data.
What is the timeout limit?
Default timeout is 10 seconds. This prevents infinite loops and runaway processes. Most computations complete well within this limit.

Get Your Free API Key

200 free credits. No Docker. No VMs. Execute code in seconds.

Get Started Free