LelantosLelantos
SDK Reference

SDK Reference

TypeScript SDK for the Lelantos sandbox platform — the @lelantos-ai/sdk package (v0.2.0)

Installation

npm install @lelantos-ai/sdk

Short alias: npm i lelantos re-exports the same package (import … from 'lelantos').

Upgrading? @lelantos-ai/sdk@0.2.0 adds compute exec, browser sandboxes, and the /rpc client plus the modern createLelantos() namespaced API. The legacy LelantosClient / SandboxHandle class API from earlier versions still works (documented below) — just npm i @lelantos-ai/sdk@latest.

LelantosClient

The legacy class-based entry point. All control-plane operations go through this class. (New code can also use the modern createLelantos() surface below — both ship in @lelantos-ai/sdk.)

import { LelantosClient } from "@lelantos-ai/sdk";

const client = new LelantosClient({
  apiKey: "lel_...",
  baseURL: "https://api.lelantos.ai", // optional, this is the default
  timeout: 30000,                      // optional, request timeout in ms
});

Sandboxes

createSandbox(opts)SandboxHandle

Create a new sandbox. Returns a SandboxHandle with convenience methods.

const sandbox = await client.createSandbox({
  templateID: "base",
  timeout: 3600,                        // optional, seconds (default: 86400)
  metadata: { project: "demo" },        // optional
  envVars: { NODE_ENV: "production" },  // optional
});

listSandboxes(metadata?)ListedSandbox[]

List all running sandboxes. Optionally filter by metadata.

listSandboxesV2(opts?)PaginatedResult<ListedSandbox>

Paginated sandbox list. Returns data array and optional nextToken.

const page = await client.listSandboxesV2({ limit: 10 });
console.log(page.data);      // ListedSandbox[]
console.log(page.nextToken);  // string | undefined

getSandbox(sandboxID)SandboxDetail

Get full details including state, resources, and metadata.

killSandbox(sandboxID)void

Immediately terminate a sandbox.

pauseSandbox(sandboxID)void

Pause a running sandbox. Resume later with resumeSandbox.

resumeSandbox(sandboxID, opts?)Sandbox

Resume a paused sandbox.

setSandboxTimeout(sandboxID, timeout)void

Set the sandbox timeout in seconds.

refreshSandbox(sandboxID, duration)void

Extend sandbox lifetime by duration seconds.

Lifecycle Events

getSandboxLogs(sandboxID, opts?)SandboxLogs

Retrieve lifecycle events for a sandbox. Works for both live and historical sandboxes — you can query events even after a sandbox has been killed.

const logs = await client.getSandboxLogs("sandbox-id", {
  start: 0,   // optional, offset for pagination
  limit: 100, // optional, max events to return (default: 1000)
});

for (const ev of logs.logs) {
  console.log(`[${ev.timestamp}] ${ev.line}`);
}
// [2026-03-06T10:00:52Z] sandbox.lifecycle.created
// [2026-03-06T10:01:15Z] sandbox.lifecycle.paused
// [2026-03-06T10:05:30Z] sandbox.lifecycle.resumed
// [2026-03-06T10:10:00Z] sandbox.lifecycle.killed

Available event types:

  • sandbox.lifecycle.created — sandbox was created
  • sandbox.lifecycle.running — sandbox started running on a node
  • sandbox.lifecycle.paused — sandbox was paused
  • sandbox.lifecycle.resumed — sandbox was resumed
  • sandbox.lifecycle.killed — sandbox was killed via API
  • sandbox.lifecycle.stopped — sandbox stopped (node confirmed)
  • sandbox.lifecycle.error — sandbox encountered an error

Metrics

getSandboxMetrics(sandboxID)SandboxMetric[]

Get sandbox resource metrics. Currently returns allocated resources (CPU count, memory, disk).

Real-time CPU/memory usage collection is coming soon.

Files

uploadFile(sandboxID, path, content)void

Upload a file to the sandbox filesystem.

await client.uploadFile("sandbox-id", "/home/user/data.json", JSON.stringify({ key: "value" }));

downloadFile(sandboxID, path)ArrayBuffer

Download a file from the sandbox filesystem.

const buf = await client.downloadFile("sandbox-id", "/home/user/data.json");
const text = new TextDecoder().decode(buf);

Templates

createTemplate(opts)Template

Build a new template from a Dockerfile. The build runs asynchronously — poll build status with getTemplateBuildStatus. Optionally set cpuCount (1–8) and memoryMB (128–8192). Defaults: 2 vCPU, 512 MB.

const template = await client.createTemplate({
  dockerfile: "FROM python:3.12\nRUN pip install numpy",
  alias: "python-numpy",  // optional human-readable name
  cpuCount: 4,             // optional (default: 2)
  memoryMB: 2048,          // optional (default: 512)
});

listTemplates(teamID?)Template[]

List all templates accessible to the team.

getTemplate(templateID)Template

Get template details including cpuCount, memoryMB, build count, and spawn count.

rebuildTemplate(templateID, opts)Template

Rebuild an existing template with a new Dockerfile.

deleteTemplate(templateID)void

Delete a template.

updateTemplate(templateID, opts)void

Update template settings (e.g. { public: true }).

getTemplateBuildStatus(templateID, buildID)TemplateBuildInfo

Check the status of a template build.

const status = await client.getTemplateBuildStatus(template.templateID, template.buildID);
// status.status: "building" | "waiting" | "ready" | "error"
// status.logs: string[] (build output)

Snapshots

createSnapshot(sandboxID, name?)SnapshotInfo

Create a point-in-time snapshot of a running sandbox.

listSnapshots(opts?)PaginatedResult<SnapshotInfo>

List snapshots, optionally filtered by sandbox ID.

API Keys

listAPIKeys()TeamAPIKey[]

List API keys for the team.

createAPIKey(name)CreatedTeamAPIKey

Create a new API key. The apiKey field is only returned once.

Store the returned apiKey value immediately. It cannot be retrieved again after creation.

deleteAPIKey(apiKeyID)void

Revoke an API key.

SandboxHandle

Returned by createSandbox(). Wraps a sandbox ID and provides convenience methods that delegate to the client.

MethodReturnsDescription
getDetails()SandboxDetailFull sandbox details
kill()voidTerminate the sandbox
pause()voidPause the sandbox
resume(timeout?)SandboxResume the sandbox
setTimeout(seconds)voidSet timeout
refresh(seconds)voidExtend lifetime
getLogs(opts?)SandboxLogsLifecycle events
getMetrics()SandboxMetric[]Resource metrics
uploadFile(path, content)voidUpload a file
downloadFile(path)ArrayBufferDownload a file
snapshot(name?)SnapshotInfoCreate snapshot
getURL(port?)string | nullSandbox URL for HTTP access

Modern Namespaced API (createLelantos)

The @lelantos-ai/sdk package also ships a modern, namespaced surface via createLelantos(). One config (key + domain) is baked into every call, and the full platform is grouped into focused namespaces:

  • lel.compute.* — E2B-compatible compute sandboxes (create / connect / list / destroy; runCommand with real exit codes; filesystem; getUrl)
  • lel.browser.* — browser sandboxes over CDP + contexts + artifacts, plus lel.browser.rpc (NDJSON action API)
  • lel.durable.* — durable pause / resume (compute only)
  • lel.snapshot.* — snapshots
  • lel.template.* — v3 template builds
import { createLelantos } from "@lelantos-ai/sdk";

const lel = createLelantos({
  apiKey: process.env.LELANTOS_API_KEY!,
  domain: "lelantos.ai",
});

// Compute
const sbx = await lel.compute.create("base");
const { stdout, exitCode } = await sbx.runCommand("echo hi");
const url = await sbx.getUrl(3000);
await sbx.destroy();

// Browser over CDP (needs `playwright`)
const { browser, artifacts, close } = await lel.browser.createBrowser({ engine: "chromium" });
await artifacts.screenshot();
await close();

// Browser via the NDJSON /rpc action API (no Playwright)
const rpc = await lel.browser.rpc(sandboxId);
await rpc.navigate("https://example.com");
await rpc.snapshot();
const { value } = await rpc.evaluate("document.title");
await rpc.close();

The legacy LelantosClient (above) and createLelantos() both ship in the same @lelantos-ai/sdk package — neither replaces the other. Use whichever fits; you can mix them in the same project.

Error Handling

import { LelantosClient, LelantosError, TimeoutError } from "@lelantos-ai/sdk";

try {
  await client.killSandbox("nonexistent");
} catch (err) {
  if (err instanceof LelantosError) {
    console.log(err.status);   // 404
    console.log(err.message);  // "sandbox not found"
  }
  if (err instanceof TimeoutError) {
    console.log("Request timed out");
  }
}

On this page