# AsyncSandbox

> **Class** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox)

Represents an active sandbox for running commands and file operations async.

This class is typically obtained from AsyncSandboxClient.sandbox() and supports
the async context manager protocol for automatic cleanup.

## Signature

```python
AsyncSandbox(
    self,
    name: str,
    template_name: Optional[str] = None,
    dataplane_url: Optional[str] = None,
    id: Optional[str] = None,
    status: str = 'ready',
    status_message: Optional[str] = None,
    created_at: Optional[str] = None,
    updated_at: Optional[str] = None,
    ttl_seconds: Optional[int] = None,
    idle_ttl_seconds: Optional[int] = None,
    expires_at: Optional[str] = None,
    snapshot_id: Optional[str] = None,
    vcpus: Optional[int] = None,
    mem_bytes: Optional[int] = None,
    fs_capacity_bytes: Optional[int] = None,
    _client: AsyncSandboxClient = None,
    _auto_delete: bool = True,
)
```

## Description

**Example:**

async with await client.sandbox(template_name="python-sandbox") as sandbox:
result = await sandbox.run("python --version")
print(result.stdout)

## Constructors

```python
__init__(
    self,
    name: str,
    template_name: Optional[str] = None,
    dataplane_url: Optional[str] = None,
    id: Optional[str] = None,
    status: str = 'ready',
    status_message: Optional[str] = None,
    created_at: Optional[str] = None,
    updated_at: Optional[str] = None,
    ttl_seconds: Optional[int] = None,
    idle_ttl_seconds: Optional[int] = None,
    expires_at: Optional[str] = None,
    snapshot_id: Optional[str] = None,
    vcpus: Optional[int] = None,
    mem_bytes: Optional[int] = None,
    fs_capacity_bytes: Optional[int] = None,
    _client: AsyncSandboxClient = None,
    _auto_delete: bool = True,
) -> None
```

| Name | Type |
|------|------|
| `name` | `str` |
| `template_name` | `Optional[str]` |
| `dataplane_url` | `Optional[str]` |
| `id` | `Optional[str]` |
| `status` | `str` |
| `status_message` | `Optional[str]` |
| `created_at` | `Optional[str]` |
| `updated_at` | `Optional[str]` |
| `ttl_seconds` | `Optional[int]` |
| `idle_ttl_seconds` | `Optional[int]` |
| `expires_at` | `Optional[str]` |
| `snapshot_id` | `Optional[str]` |
| `vcpus` | `Optional[int]` |
| `mem_bytes` | `Optional[int]` |
| `fs_capacity_bytes` | `Optional[int]` |
| `_client` | `AsyncSandboxClient` |
| `_auto_delete` | `bool` |


## Properties

- `name`
- `template_name`
- `dataplane_url`
- `id`
- `status`
- `status_message`
- `created_at`
- `updated_at`
- `ttl_seconds`
- `idle_ttl_seconds`
- `expires_at`
- `snapshot_id`
- `vcpus`
- `mem_bytes`
- `fs_capacity_bytes`

## Methods

- [`from_dict()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/from_dict)
- [`run()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/run)
- [`reconnect()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/reconnect)
- [`write()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/write)
- [`read()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/read)
- [`tunnel()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/tunnel)
- [`service()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/service)
- [`start()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/start)
- [`stop()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/stop)
- [`delete()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/delete)
- [`capture_snapshot()`](https://reference.langchain.com/python/langsmith/sandbox/_async_sandbox/AsyncSandbox/capture_snapshot)

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/ce9e9e8973442b33e98ec3ce1b9c2dd3f58a43a7/python/langsmith/sandbox/_async_sandbox.py#L34)