SandboxesRun Python

Run Python

Run Python with the interpreter template. Each process command starts a separate Python process, so Python variables do not survive between calls. Save intermediate results to files. The API returns stdout, stderr, and an exit code; it does not return typed notebook results or chart objects.

import { Sandbox } from '@lizard-build/sdk';
 
const sandbox = await Sandbox.create('interpreter', {
  projectId: 'proj_123', timeoutMs: 300_000,
});
try {
  const result = await sandbox.process.exec("python -c 'print(2 ** 10)'");
  console.log(result.stdout, result.stderr, result.exitCode);
} finally {
  await sandbox.kill();
}
from lizard import Sandbox
 
sandbox = Sandbox.create("interpreter", project_id="proj_123", timeout_ms=300_000)
try:
    result = sandbox.process.exec_("python -c 'print(2 ** 10)'")
    print(result.stdout, result.stderr, result.exit_code)
finally:
    sandbox.kill()

Unsupported APIs

CodeSandbox, runCode / run_code, and execution-context methods remain in the SDK, but the hosted template catalog does not provide their required execution server. The legacy default code-interpreter-v1 is unavailable. Changing its name to interpreter does not enable this API. Use Sandbox.create("interpreter") and process commands as shown below.

Storage and billing

Files and running processes remain available while the sandbox runs. After it stops, only files written to an attached Persistent Volume at /workspace can be reused by a later sandbox. Without a volume, /workspace is temporary. Each volume attaches to one sandbox at a time and uses node-local storage; export files that must survive node loss.

Quickstart · SDK reference · Run Python · Dashboard · Persistent Volumes

Updated