SandboxesCode Sandbox
Code Sandbox Endpoints
Execute Code
Run code securely in isolated sandbox environments. Each execution runs in its own isolated subprocess inside a Kata micro-VM with no network access.
Secure by Design
Code runs in isolated Kata micro-VMs with no network access. Each execution is ephemeral - environments are destroyed immediately after completion.
POST
/v1/code-sandbox/executeExecute code in an isolated code sandbox environment.
Request Body
| Parameter | Type | Description |
|---|---|---|
coderequired | string | The code to execute in the Code Sandbox |
languagerequired | "python" | "javascript" | Programming language runtime to use |
Example Request
Example Response
Multi-line Code with Imports
You can execute multi-line code with imports and complex logic.
Python Example
JavaScript Example
Example Response
Using the SDK
The Node.js SDK provides a simple interface for code execution:
Response Fields
| Field | Type | Description |
|---|---|---|
stdout | string | Standard output from the code execution |
stderr | string | Standard error output from the code execution |
exitCode | number | Exit code (0 = success, 124 = timeout) |
executionTimeMs | number | Time taken to execute the code in milliseconds |
memoryUsageMb | number | Peak memory usage during execution in megabytes |
timedOut | boolean | Whether the execution timed out |
error | string | Error message if execution infrastructure failed |
cost | number | Cost of the request in USD |
Pre-installed Libraries
The following libraries are pre-installed and ready to use. No installation or network access is needed.
Python
Python 3.12 with the full standard library, plus:
numpypandassympypython-dateutilPillow
JavaScript
Node.js 22 with CommonJS modules (
require() syntax), plus:lodashdayjsmathjs
Pricing
Each code execution costs
$0.002 USD (~$2.00 per 1000 executions). Cost is charged regardless of whether the code succeeds or fails.Execution Limits
Code Sandbox executions have the following limits to ensure fair usage:
| Limit | Value | Description |
|---|---|---|
| Timeout | 10 seconds | Maximum execution time before timeout |
| Memory | 256 MB | Maximum memory allocation per execution |
| CPU | 0.5 cores | CPU allocation per execution |
| Code size | 100 KB | Maximum size of submitted code |
| Output | 1 MB | Maximum stdout/stderr output size |
| Network | None | No network access from sandbox |
Error Handling
When code execution fails, the response will contain error information:
When execution times out (exceeds 10 seconds):