Overview
The Code Execution API lets you run code in any supported language with a single API call. Code runs in fully isolated sandboxes with per-execution process, filesystem, and resource isolation.- 11 languages — Python, JavaScript, TypeScript, Bash, C, C++, Go, Ruby, Rust, Java, C#
- Millisecond overhead — sandboxes are created in ~5ms, no VM boot needed
- Session persistence — reuse sandboxes across requests, files persist between executions
- Secure — each execution runs in its own isolated environment with resource limits
- Simple API — just send
languageandcode, getstdoutback
Supported Languages
| Language | Version | Compiled | Typical Execution Time |
|---|---|---|---|
| Python | 3.12 | No | ~30ms |
| JavaScript | Node 22 | No | ~85ms |
| TypeScript | Node 22 | No | ~90ms |
| Bash | 5.2 | No | ~3ms |
| C | gcc 13 | Yes | ~1ms (after compile) |
| C++ | g++ 13 | Yes | ~3ms (after compile) |
| Go | 1.22 | Yes | ~500ms (compile heavy) |
| Ruby | 3.2 | No | ~50ms |
| Rust | stable | Yes | ~1s (compile heavy) |
| Java | OpenJDK 21 | Yes | ~500ms (JVM startup) |
| C# | .NET 10 | No | ~800ms (warm) |
API
Execute Code
| Field | Type | Required | Description |
|---|---|---|---|
language | string | Yes | Language identifier (see table above) |
code | string | Yes* | Code to execute (shorthand for single file) |
files | array | Yes* | Array of { name, content } for multi-file support |
stdin | string | No | Standard input to pass to the program |
session_id | string | No | Reuse a persistent sandbox (files persist between requests) |
version | string | No | Version selector (default: * = latest) |
run_timeout | number | No | Run timeout in ms (default: 300000 = 5 minutes) |
compile_timeout | number | No | Compile timeout in ms (default: 60000 = 1 minute) |
code or files must be provided.
Response
session_id. Pass it back in subsequent requests to reuse the same sandbox — files, env vars, and installed packages persist within the session.
For compiled languages, the response includes a compile field:
Sessions
Sessions let you maintain state across multiple execution requests:List Runtimes
SDK
CLI
Examples
Security
Each execution runs in a fully isolated sandbox with:- Process isolation — separate process namespace, cannot see other processes
- Filesystem isolation — minimal filesystem, read-only system directories
- Resource limits — CPU time, wall time, memory, file size, and process count limits
- Network disabled — no outbound connections from executed code
- Unprivileged execution — code runs without elevated privileges
- Session isolation — each session has its own filesystem; sessions are cleaned up after 10 minutes of inactivity
Architecture
Code execution runs on dedicated infrastructure separate from sandbox VMs:- Requests are authenticated and routed to the best available execution node
- Each node runs multiple isolated sandboxes in parallel
- Horizontal scaling — add more nodes, they are auto-discovered
- Sessions persist across requests within a node; cleaned up after idle timeout
Use Cases
AI Agent Code Execution
Run code generated by AI agents to verify correctness, process data, or interact with APIs
Code Evaluation
Evaluate user-submitted code safely in isolated sandboxes for assessments or competitions
Data Processing
Run Python/R scripts for data transformation, analysis, or report generation
Education
Interactive coding environments for tutorials, courses, and coding challenges