Overview
The Code Execution API runs code in ephemeral sandboxes:- Stateless - Each execution is isolated
- Fast - Optimized for quick execution
- Multi-runtime - Python, Node.js, Go, Rust, and more
- Isolated - Each execution runs in its own sandbox
Quick Start
Supported Runtimes
| Runtime | Identifier | Version |
|---|---|---|
| Python | python | 3.12 |
| Node.js | node | 22 |
| Bun | bun | latest |
| Deno | deno | latest |
| Go | go | 1.23 |
| Rust | rust | 1.80 |
Examples
Python
Node.js
Go
Rust
Multiple Files
Execute with multiple files:Timeouts
Set execution timeouts:Stdin Input
Provide input to the program:Error Handling
CLI Usage
API Reference
Request
Response
Use Cases
Code Evaluation
Evaluate user-submitted code safely in isolated environments
AI Code Generation
Run code generated by AI models to verify correctness
Notebooks
Build Jupyter-like notebook experiences
Education
Run student code submissions for grading
Pricing
| Tier | Executions/Month | Price |
|---|---|---|
| Free | 1,000 | $0 |
| Pro | 50,000 | $29/mo |
| Team | 500,000 | $99/mo |
| Enterprise | Unlimited | Custom |
Best Practices
Set appropriate timeouts
Set appropriate timeouts
Don’t let code run forever. Set timeouts based on expected execution time.
Handle errors gracefully
Handle errors gracefully
Check
exitCode and stderr to handle execution failures.Use files for complex code
Use files for complex code
For anything beyond a few lines, use the
files parameter for better organization.Consider sandboxes for stateful work
Consider sandboxes for stateful work
If you need persistent state or multiple executions, use a sandbox instead.