Skip to main content
A snapshot is a reusable filesystem bundle backed by a Docker image. Build or capture a snapshot when you want to boot sandboxes from a custom filesystem image. You can also capture a snapshot from a running sandbox—install packages, write data files, or configure state, then snapshot the result and reuse it as a new starting point. Sandboxes snapshots page

Build a snapshot from a Docker image

Build a snapshot by pointing at any Docker image. The call blocks until the snapshot is ready (default timeout is 60 seconds; bump it for large images).

Private registries

To pull from a private registry, create a registry once with its credentials, then reference it by id when building a snapshot. Registries persist, so reuse one across snapshots.
List, inspect, update, and delete registries with client.registries.list(), client.registries.retrieve(name), client.registries.update(name, ...), and client.registries.delete(name).

Build a snapshot from a Dockerfile

When you have a local Dockerfile but don’t want to publish the image to a registry first, build a snapshot directly from the Dockerfile and its build context. LangSmith spins up a temporary builder sandbox, uploads the context, runs the build inside it with BuildKit, and captures the resulting image as a snapshot. The builder sandbox is torn down automatically once the build finishes. The call blocks until the snapshot is ready (default timeout is 60 seconds; raise it for large or slow builds). fs_capacity_bytes must be large enough to hold the build context, the intermediate layers, and the final image.
dockerfile is resolved relative to context unless you pass an absolute path, and it must live inside the context directory. The .git directory is excluded from the uploaded context automatically.

Build args and target stage

Pass build_args / buildArgs to set Docker ARG values, and target to stop at a specific stage of a multi-stage build.

Stream build logs

Pass a callback to on_build_log / onBuildLog to receive the build’s stdout and stderr as it runs, which is useful for surfacing progress or debugging a failing build.

Speed up cold builds

vcpus / vCpus and mem_bytes / memBytes size the temporary builder sandbox. The build runs BuildKit plus the native snapshotter’s layer copies inside it, which contend for the builder’s default 0.5 vCPU, so giving the builder more CPU can cut a cold build’s wall time substantially. Memory is tied to CPU at 4 GiB per vCPU and must stay within 50% of that target, so a 2-vCPU builder accepts 4 to 12 GiB. Omit memory and it follows the ratio.
Both the sync SandboxClient and the AsyncSandboxClient expose this method with the same arguments—await client.create_snapshot_from_dockerfile(...) on the async client.

Capture a snapshot from a running sandbox

Start a sandbox from an existing snapshot, install packages or prepare data, then capture the result as a new snapshot. The returned snapshot has its source_sandbox_id set to the sandbox it was captured from, and can be used as the snapshot_id for any later create_sandbox call.
By default, capture preserves the filesystem only. Installed packages (under /usr/local, /root, /opt, the home directory, etc.) and files you wrote to those locations are kept, as is /tmp. Only /dev/shm is a tmpfs, so everything else lives on the sandbox’s disk. Running processes, open sockets, and in-memory state are not carried over: boot the new sandbox and start the processes you need again, or capture memory too.
You can boot a sandbox from a snapshot by name instead of ID — handy when you know the human-readable label you captured with:
Pass at most one of snapshot_id / snapshot_name (or snapshotId / snapshotName in TypeScript). Omit both to use the default runtime.

Tune capture timing

capture_snapshot blocks until the new snapshot is ready. Raise the timeout kwarg (default 60s) if your filesystem is large or your storage backend is slow.

Resume from memory

A snapshot can carry the sandbox’s RAM alongside its filesystem. Boot from one and the sandbox resumes where it left off, with its processes still running, instead of cold-booting. Use this for environments that are slow to warm up, such as a loaded model or a started database.
Memory snapshots are available over the REST API only. The langsmith.sandbox Python and TypeScript clients do not expose these fields yet.
Capture memory by setting include_memory on a capture:
The response reports memory_snapshot_size_bytes when memory was captured. include_memory requires a sandbox that is running or stopped, and it cannot be combined with checkpoint or docker_image. Some sandboxes run on an overlay filesystem runtime that cannot carry a memory image. Capturing one returns include_memory is not supported for overlay-rootfs sandboxes. LangSmith assigns that runtime, so it is not something you select per sandbox. Two fields on create control the other half:
Capturing memory from a stopped sandbox only works when that sandbox was created with preserve_memory_on_stop. Without it, the stop discards RAM and there is nothing to capture.

List, fetch, and delete snapshots

list_snapshots / listSnapshots paginates server-side (default page size 50, max 500) and accepts optional filters: name_contains / nameContains (case-insensitive substring on name), limit (1–500), and offset (≥ 0). Page through results by advancing offset.

Stopped sandboxes

A stopped sandbox keeps its filesystem, and the next request wakes it automatically. You do not need to start it yourself: send the command you wanted to run and the sandbox comes back up to serve it.
The first request after a stop pays the boot cost, so it is slower than the ones that follow. Create the sandbox with preserve_memory_on_stop to resume from memory instead of cold-booting.

Next steps