Async client for interacting with the Sandbox Server API.
This client provides an async interface for managing sandboxes and templates.
AsyncSandboxClient(
self,
*,
api_endpoint: Optional[str] = None,
timeout: float = 10.0,
api_key: Optional[str] = None
)Example:
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)
| Name | Type | Description |
|---|---|---|
api_endpoint | Optional[str] | Default: NoneFull URL of the sandbox API endpoint. If not provided, derived from LANGSMITH_ENDPOINT environment variable. |
timeout | float | Default: 10.0Default HTTP timeout in seconds. |
api_key | Optional[str] | Default: NoneAPI key for authentication. If not provided, uses LANGSMITH_API_KEY environment variable. |
Close the async HTTP client.
Create a new persistent volume.
Creates a persistent storage volume that can be referenced in templates.
Get a volume by name.
List all volumes.
Delete a 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).
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.
Get a SandboxTemplate by name.
List all SandboxTemplates.
Update a template's display name.
Delete a SandboxTemplate.
Create a new Sandbox Pool.
Pools pre-provision sandboxes from a template for faster startup.
Get a Pool by name.
List all Pools.
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.
Delete a Pool.
This will terminate all sandboxes in the pool.
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().
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.
Get a Sandbox by name.
The sandbox is NOT automatically deleted. Use delete_sandbox() for cleanup.
List all Sandboxes.
Update a sandbox's display name.
Delete a Sandbox.