> ## Documentation Index
> Fetch the complete documentation index at: https://sandbox-docs.thundercompute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox

> Python API reference for creating and working with Thunder sandboxes.

Import the `thunder` package to create a sandbox and run commands in it.

```python theme={null}
import thunder
```

## `Sandbox.create`

Creates a new sandbox with the requested compute and storage resources.

```python theme={null}
sandbox = thunder.Sandbox.create(cpu=4, memory=32, storage=50)
```

<ParamField body="cpu" type="integer" required>
  Number of CPU cores to allocate.
</ParamField>

<ParamField body="memory" type="integer" required>
  Amount of memory to allocate.
</ParamField>

<ParamField body="storage" type="integer" required>
  Amount of storage to allocate.
</ParamField>

Returns a `Sandbox` object immediately. Call `wait_until_running()` before
executing commands.

## `Sandbox.wait_until_running`

Waits until the sandbox is ready to accept commands.

```python theme={null}
sandbox.wait_until_running()
```

## `Sandbox.exec`

Starts a command in the sandbox. Pass the executable as the first positional
argument and each command-line argument separately.

```python theme={null}
process = sandbox.exec("uname", "-a")
```

<ParamField body="command" type="string" required>
  Executable to run in the sandbox.
</ParamField>

<ParamField body="*args" type="string">
  Command-line arguments passed to the executable.
</ParamField>

Returns a process object. Read its standard output with `process.stdout.read()`
and wait for it to finish with `process.wait()`.

## `Process.stdout.read`

Reads the command's standard output.

```python theme={null}
print(process.stdout.read())
```

## `Process.wait`

Waits for the command to finish.

```python theme={null}
process.wait()
```

## `Sandbox.terminate`

Terminates the sandbox and releases its resources.

```python theme={null}
sandbox.terminate()
```

Terminate a sandbox when you no longer need it.
