Skip to main content
Sandboxes are isolated environments that allow agents to safely execute potentially risky operations—like running arbitrary code or interacting with the filesystem—without affecting your main infrastructure. From the LangSmith homepage, select Sandboxes to manage all your sandbox resources. Sandboxes overview page

Get started

1. Install the SDK

# uv
uv add "langsmith[sandbox]"

# pip
pip install "langsmith[sandbox]"

2. Set your API key

export LANGSMITH_API_KEY="<your-api-key>"

3. Create and run a sandbox

from langsmith.sandbox import SandboxClient

client = SandboxClient()

with client.sandbox() as sb:
    result = sb.run("python -c 'print(2 + 2)'")
    print(result.stdout)  # "4\n"
Prefer the command line? The Sandbox CLI lets you create sandboxes, run commands, and open interactive shells without writing any code.

4. Use sandboxes with your agents

To wire sandboxes into agent code, see the Open Source docs:
  • Deep AgentsSandboxes as agent backends: configure a sandbox as the execution backend so your agent gets execute and filesystem tools automatically.
  • LangChain / LangGraph integrationsSandbox integrations: connect to third-party sandbox providers (Daytona, Modal, etc.) or use LangSmith sandboxes as a first-party option.

Resources

Snapshots

Build filesystem images from Docker images or capture a running sandbox, then boot sandboxes from them.

Service URLs

Access HTTP services running inside sandboxes via authenticated URLs.

Auth proxy

Inject credentials into outbound API requests without hardcoding secrets.

Permissions

Control which workspace members can interact with a sandbox after it is created.

CLI

Build snapshots, manage sandboxes, open consoles, and tunnel TCP ports from the command line.

SDK usage

Create and manage sandboxes programmatically with the Python or TypeScript SDK.