Code Interpreter

Run code through the sandbox's built-in interpreter — stateless and stateful modes.

exec-code

Demonstrates sb.execCode() for running code through the sandbox's built-in interpreter — stateless one-shot calls and stateful sessions where variables persist across calls.

Setup

bunx alineo-cli init   # starts OpenSandbox in Docker (one-time setup)

Run

bun install
bun start

What it shows

ModeDescription
StatelessEach execCode() call runs in an isolated context; no shared state
StatefulCalls sharing the same context object see each other's variables

Uses the opensandbox/code-interpreter image, which ships a Python interpreter accessible via the execd /code endpoint.