LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
  • RemoteGraph
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDKRemoteGraph
Language
Theme
Pythonlangsmithsandbox_async_clientAsyncSandboxClient
Class●Since v0.6

AsyncSandboxClient

Async client for interacting with the Sandbox Server API.

This client provides an async interface for managing sandboxes and templates.

Copy
AsyncSandboxClient(
  self,
  *,
  api_endpoint: Optional[str] = None,
  timeout: float = 10.0,
  api_key: Optional[str] = None
)

Example:

Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment

async with AsyncSandboxClient() as client: # Create a sandbox and run commands async with await client.sandbox(template_name="python-sandbox") as sandbox: result = await sandbox.run("python --version") print(result.stdout)

Parameters

NameTypeDescription
api_endpointOptional[str]
Default:None

Full URL of the sandbox API endpoint. If not provided, derived from LANGSMITH_ENDPOINT environment variable.

timeoutfloat
Default:10.0

Default HTTP timeout in seconds.

api_keyOptional[str]
Default:None

API key for authentication. If not provided, uses LANGSMITH_API_KEY environment variable.

Constructors

constructor
__init__
NameType
api_endpointOptional[str]
timeoutfloat
api_keyOptional[str]

Methods

method
aclose

Close the async HTTP client.

method
create_volume

Create a new persistent volume.

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

method
get_volume

Get a volume by name.

method
list_volumes

List all volumes.

method
delete_volume

Delete a volume.

method
update_volume

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).

method
create_template

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.

method
get_template

Get a SandboxTemplate by name.

method
list_templates

List all SandboxTemplates.

method
update_template

Update a template's display name.

method
delete_template

Delete a SandboxTemplate.

method
create_pool

Create a new Sandbox Pool.

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

method
get_pool

Get a Pool by name.

method
list_pools

List all Pools.

method
update_pool

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.

method
delete_pool

Delete a Pool.

This will terminate all sandboxes in the pool.

method
sandbox

Create a sandbox and return an AsyncSandbox instance.

This is the primary method for creating sandboxes. Use it as an async context manager for automatic cleanup:

async with await client.sandbox(template_name="my-template") as sandbox:
    result = await sandbox.run("echo hello")

The sandbox is automatically deleted when exiting the context manager. For sandboxes with manual lifecycle management, use create_sandbox().

method
create_sandbox

Create a new Sandbox.

The sandbox is NOT automatically deleted. Use delete_sandbox() for cleanup, or use sandbox() for automatic cleanup with a context manager.

method
get_sandbox

Get a Sandbox by name.

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

method
list_sandboxes

List all Sandboxes.

method
update_sandbox

Update a sandbox's display name.

method
delete_sandbox

Delete a Sandbox.

View source on GitHub