---
title: LangSmith Sandboxes
sidebarTitle: Overview
description: Use LangSmith managed sandboxes to safely execute code and interact with the filesystem in isolated environments.
keywords: ["sandbox", "sandboxes", "LangSmith sandboxes", "managed sandboxes"]
boost: 1.5
---
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](https://smith.langchain.com), select **Sandboxes** to manage all your sandbox resources.

## Availability
Sandboxes are generally available in all [LangSmith Cloud regions](/langsmith/cloud#regional-storage), on [BYOC](/langsmith/byoc), and on [self-hosted](/langsmith/enable-self-hosted-sandboxes) deployments. On BYOC, use an API key that belongs to a BYOC workspace.
For the self-hosted infrastructure model, scaling, and upgrades, see [Self-hosted Sandbox architecture](/langsmith/self-host-sandbox-architecture).
## Network access
Restricted egress applies to non-Enterprise organizations by default and to organizations that request it. Organizations with an approved exemption can use unrestricted egress. Restricted sandboxes use a managed allowlist for common package registries, source repositories, and model APIs. LangSmith blocks destinations outside the allowlist, even if you add them to a sandbox's proxy configuration.
If you need unrestricted egress, [file a support ticket](https://support.langchain.com) with your organization or workspace ID, region, required destinations and ports, and use case. For more information, see [restricted egress and access requests](/langsmith/sandbox-auth-proxy#organization-level-restricted-egress).
## Get started
### 1. Install the SDK
```bash Python
# uv
uv add langsmith
# pip
pip install langsmith
```
```bash TypeScript
npm install langsmith
```
### 2. Set your API key
```bash
export LANGSMITH_API_KEY=""
```
### 3. Create and run a sandbox
```python Python
from langsmith.sandbox import SandboxClient
client = SandboxClient()
with client.sandbox() as sb:
result = sb.run("python3 -c 'print(2 + 2)'")
print(result.stdout) # "4\n"
```
```ts TypeScript
import { SandboxClient } from "langsmith/sandbox";
const client = new SandboxClient();
const sandbox = await client.createSandbox();
const result = await sandbox.run("node -e 'console.log(2 + 2)'");
console.log(result.stdout); // "4\n"
await sandbox.delete();
```
Prefer the command line? The [Sandbox CLI](/langsmith/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 documentation:
- **Deep Agents**: [Use `LangSmithSandbox` as a backend](/oss/integrations/sandboxes/langsmith), covering installation, backend creation, and cleanup.
- **Sandboxes as agent backends**: [Configure any sandbox as the execution backend](/oss/deepagents/sandboxes) to give your agent `execute` and filesystem tools automatically.
- **LangChain / LangGraph integrations**: Use LangSmith sandboxes as a first-party option, or [connect third-party providers](/oss/integrations/sandboxes) such as AgentCore, Daytona, E2B, Modal, Runloop, and Vercel.
## Resources
Build filesystem images from Docker images or capture a running sandbox, then boot sandboxes from them.
Access HTTP services running inside sandboxes via authenticated URLs.
Inject credentials into outbound API requests without hardcoding secrets.
Attach S3 buckets, GCS buckets, and public Git repositories to a sandbox filesystem.
Control which workspace members can interact with a sandbox after it is created.
Build snapshots, manage sandboxes, open consoles, and tunnel TCP ports from the command line.
Create and manage sandboxes programmatically with the Python or TypeScript SDK.
Enable Sandboxes on self-hosted LangSmith deployments with Helm or Terraform.
Run Harbor evaluations and rollouts on LangSmith sandboxes.