langchain.js
    Preparing search index...

    Client for interacting with the Sandbox Server API.

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

    import { SandboxClient } from "langsmith/experimental/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 and run commands
    const sandbox = await client.createSandbox("python-sandbox");
    try {
    const result = await sandbox.run("python --version");
    console.log(result.stdout);
    } finally {
    await sandbox.delete();
    }
    Index

    Constructors

    Methods

    • Create a new Sandbox Pool.

      Pools pre-provision sandboxes from a template for faster startup.

      Parameters

      • name: string

        Pool name (lowercase letters, numbers, hyphens; max 63 chars).

      • options: CreatePoolOptions

        Creation options including templateName, replicas, and optional timeout.

      Returns Promise<Pool>

      Created Pool.

      LangSmithResourceNotFoundError if template not found.

      ValidationError if template has volumes attached.

      ResourceAlreadyExistsError if pool with this name already exists.

      ResourceTimeoutError if pool doesn't reach ready state within timeout.

      QuotaExceededError if organization quota is exceeded.

    • Create a new Sandbox.

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

      Parameters

      • templateName: string

        Name of the SandboxTemplate to use.

      • options: CreateSandboxOptions = {}

        Creation options.

      Returns Promise<Sandbox>

      Created Sandbox.

      ResourceTimeoutError if timeout waiting for sandbox to be ready.

      SandboxCreationError if sandbox creation fails.

      const sandbox = await client.createSandbox("python-sandbox");
      try {
      const result = await sandbox.run("echo hello");
      console.log(result.stdout);
      } finally {
      await sandbox.delete();
      }
    • Create a new SandboxTemplate.

      Only the container image, resource limits, and volume mounts can be configured. All other container details are handled by the server.

      Parameters

      • name: string

        Template name.

      • options: CreateTemplateOptions

        Creation options including image and resource limits.

      Returns Promise<SandboxTemplate>

      Created SandboxTemplate.

    • Create a new persistent volume.

      Creates a persistent storage volume that can be referenced in templates.

      Parameters

      • name: string

        Volume name.

      • options: CreateVolumeOptions

        Creation options including size and optional timeout.

      Returns Promise<Volume>

      Created Volume.

      SandboxCreationError if volume provisioning fails.

      ResourceTimeoutError if volume doesn't become ready within timeout.

    • Delete a Pool.

      This will terminate all sandboxes in the pool.

      Parameters

      • name: string

        Pool name.

      Returns Promise<void>

      LangSmithResourceNotFoundError if pool not found.

    • Delete a Sandbox.

      Parameters

      • name: string

        Sandbox name.

      Returns Promise<void>

      LangSmithResourceNotFoundError if sandbox not found.

    • Delete a SandboxTemplate.

      Parameters

      • name: string

        Template name.

      Returns Promise<void>

      LangSmithResourceNotFoundError if template not found.

      ResourceInUseError if template is referenced by sandboxes or pools.

    • Delete a volume.

      Parameters

      • name: string

        Volume name.

      Returns Promise<void>

      LangSmithResourceNotFoundError if volume not found.

      ResourceInUseError if volume is referenced by templates.

    • Get a Pool by name.

      Parameters

      • name: string

        Pool name.

      Returns Promise<Pool>

      Pool.

      LangSmithResourceNotFoundError if pool not found.

    • Get a Sandbox by name.

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

      Parameters

      • name: string

        Sandbox name.

      Returns Promise<Sandbox>

      Sandbox.

      LangSmithResourceNotFoundError if sandbox not found.

    • Get a SandboxTemplate by name.

      Parameters

      • name: string

        Template name.

      Returns Promise<SandboxTemplate>

      SandboxTemplate.

      LangSmithResourceNotFoundError if template not found.

    • Get a volume by name.

      Parameters

      • name: string

        Volume name.

      Returns Promise<Volume>

      Volume.

      LangSmithResourceNotFoundError if volume not found.

    • List all Pools.

      Returns Promise<Pool[]>

      List of Pools.

    • List all Sandboxes.

      Returns Promise<Sandbox[]>

      List of Sandboxes.

    • List all SandboxTemplates.

      Returns Promise<SandboxTemplate[]>

      List of SandboxTemplates.

    • List all volumes.

      Returns Promise<Volume[]>

      List of Volumes.

    • Update a Pool's name and/or replica count.

      You can update the display name, replica count, or both. The template reference cannot be changed after creation.

      Parameters

      Returns Promise<Pool>

      Updated Pool.

      LangSmithResourceNotFoundError if pool not found.

      ValidationError if template was deleted.

      LangSmithResourceNameConflictError if newName is already in use.

      QuotaExceededError if quota exceeded when scaling up.

    • Update a sandbox's display name.

      Parameters

      • name: string

        Current sandbox name.

      • newName: string

        New display name.

      Returns Promise<Sandbox>

      Updated Sandbox.

      LangSmithResourceNotFoundError if sandbox not found.

      LangSmithResourceNameConflictError if newName is already in use.

    • Update a template.

      Parameters

      Returns Promise<SandboxTemplate>

      Updated SandboxTemplate.

      LangSmithResourceNotFoundError if template not found.

      LangSmithResourceNameConflictError if newName is already in use.

    • Update a volume's name and/or size.

      You can update the display name, size, or both in a single request. Only storage size increases are allowed (storage backend limitation).

      Parameters

      Returns Promise<Volume>

      Updated Volume.

      LangSmithResourceNotFoundError if volume not found.

      ValidationError if storage decrease attempted.

      LangSmithResourceNameConflictError if newName is already in use.