LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangSmith
  • Client
  • Run Trees
  • Traceable
  • Evaluation
  • Schemas
  • Langchain
  • Jest
  • Vitest
  • Wrappers
  • Anonymizer
  • Jestlike
  • Vercel
  • Anthropic
  • Sandbox
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangSmith
ClientRun TreesTraceableEvaluationSchemasLangchainJestVitestWrappersAnonymizerJestlikeVercelAnthropicSandbox
Language
Theme
JavaScriptlangsmithsandboxSandboxClient
Class●Since v0.8

SandboxClient

Client for interacting with the Sandbox Server API.

This client provides a simple interface for managing sandboxes and snapshots.

Copy
class SandboxClient

Used in Docs

  • Sandbox auth proxy
  • Sandbox SDK usage
  • Sandbox snapshots

Example

Copy
import { SandboxClient } from "langsmith/sandbox";

// Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
const client = new SandboxClient();

// Or with explicit configuration
const client = new SandboxClient({
  apiEndpoint: "https://api.smith.langchain.com/v2/sandboxes",
  apiKey: "your-api-key",
});

// Create a sandbox with the default runtime
const sandbox = await client.createSandbox();
try {
  const result = await sandbox.run("python --version");
  console.log(result.stdout);
} finally {
  await sandbox.delete();
}

Constructors

constructor
constructor

Methods

method
captureSnapshot→ Promise<Snapshot>

Capture a snapshot from this sandbox.

method
createSandbox→ Promise<Sandbox>

Create a new Sandbox.

Remember to call sandbox.delete() when done to clean up resources.

method
createSnapshot→ Promise<Snapshot>

Build a snapshot from a Docker image.

Blocks until the snapshot is ready (polls with 2s interval).

method
deleteSandbox→ Promise<void>

Delete a Sandbox.

method
deleteSnapshot→ Promise<void>

Delete a snapshot.

method
getSandbox→ Promise<Sandbox>

Get a Sandbox by name.

The sandbox is NOT automatically deleted. Use deleteSandbox() for cleanup.

method
getSandboxStatus→ Promise<ResourceStatus>

Get the provisioning status of a sandbox.

This is a lightweight endpoint designed for polling during async creation. Use this instead of getSandbox() when you only need the status.

method
getSnapshot→ Promise<Snapshot>

Get a snapshot by ID.

method
listSandboxes→ Promise<Sandbox[]>

List all Sandboxes.

method
listSnapshots→ Promise<Snapshot[]>

List snapshots, optionally filtered and paginated server-side.

The backend always paginates this endpoint. When limit is omitted the server applies a default page size (currently 50), so a single call is not guaranteed to return every snapshot visible to the tenant. To iterate through all results, repeat the call with increasing offset values (or an explicit limit) until fewer than limit snapshots come back.

method
startSandbox→ Promise<Sandbox>

Start a stopped sandbox and wait until ready.

method
stopSandbox→ Promise<void>

Stop a running sandbox (preserves sandbox files for later restart).

method
toString→ string

Returns a string representation of the Client instance. This method is called when the object is converted to a string or logged, ensuring sensitive information like API keys is not exposed.

method
updateSandbox→ Promise<Sandbox>

Update a sandbox's display name.

method
waitForSandbox→ Promise<Sandbox>

Wait for a sandbox to become ready.

Polls getSandboxStatus() until the sandbox reaches "ready" or "failed" status, then returns the full Sandbox object.

method
waitForSnapshot→ Promise<Snapshot>

Poll until a snapshot reaches "ready" or "failed" status.

View source on GitHub