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

# Python Quick Start

> Get up and running with BoxLite Python SDK in 5 minutes.

## Installation

```bash theme={null}
pip install boxlite
```

**Requirements:**

* Python 3.10 or later
* pip 20.0+

**Verify Installation:**

```python theme={null}
python3 -c "import boxlite; print(boxlite.__version__)"
```

## Basic Execution

<Steps>
  <Step title="Create a file hello.py">
    ```python theme={null}
    import asyncio
    import boxlite


    async def main():
        # Create a box and run a command
        async with boxlite.SimpleBox(image="python:slim") as box:
            result = await box.exec("python", "-c", "print('Hello from BoxLite!')")
            print(result.stdout)
            # Output: Hello from BoxLite!


    if __name__ == "__main__":
        asyncio.run(main())
    ```
  </Step>

  <Step title="Run it">
    ```bash theme={null}
    python hello.py
    ```
  </Step>
</Steps>

**What's happening:**

1. BoxLite pulls the `python:slim` OCI image (first run only)
2. Creates a lightweight VM with the image
3. Executes the Python command inside the VM
4. Streams output back to your application
5. Automatically cleans up when the context exits

## Code Execution (AI Agents)

<Steps>
  <Step title="Create a file codebox.py">
    ```python theme={null}
    import asyncio
    import boxlite


    async def main():
        # Execute untrusted code safely
        code = """
    import requests
    response = requests.get('https://api.github.com/zen')
    print(response.text)
    """

        async with boxlite.CodeBox() as codebox:
            result = await codebox.run(code)
            print(result)


    if __name__ == "__main__":
        asyncio.run(main())
    ```
  </Step>

  <Step title="Run it">
    ```bash theme={null}
    python codebox.py
    ```
  </Step>
</Steps>

**What's happening:**

1. CodeBox automatically installs required packages (requests)
2. Executes the code in complete isolation
3. Returns the output
4. Your host system remains completely safe

## Running Examples

BoxLite includes 9 comprehensive Python examples:

```bash theme={null}
# Clone the repository
git clone https://github.com/boxlite-ai/boxlite.git
cd boxlite

# Build Python SDK
make dev:python

# Run examples
python examples/python/simplebox_example.py
python examples/python/codebox_example.py
python examples/python/browserbox_example.py
python examples/python/computerbox_example.py
python examples/python/lifecycle_example.py
python examples/python/list_boxes_example.py
python examples/python/cross_process_example.py
python examples/python/interactivebox_example.py
python examples/python/native_example.py
```

**Examples overview:**

| # | Example                        | Description              |
| - | ------------------------------ | ------------------------ |
| 1 | **simplebox\_example.py**      | Foundation patterns      |
| 2 | **codebox\_example.py**        | AI code execution        |
| 3 | **browserbox\_example.py**     | Browser automation       |
| 4 | **computerbox\_example.py**    | Desktop automation       |
| 5 | **lifecycle\_example.py**      | Box lifecycle management |
| 6 | **list\_boxes\_example.py**    | Runtime introspection    |
| 7 | **cross\_process\_example.py** | Multi-process operations |
| 8 | **interactivebox\_example.py** | Interactive shells       |
| 9 | **native\_example.py**         | Low-level Rust API       |

## Next Steps

<CardGroup cols={2}>
  <Card title="Core concepts" icon="lightbulb" href="/getting-started/core-concepts">
    Understand the different box types (SimpleBox, CodeBox, BrowserBox, and more), lifecycle, images, and resource configuration.
  </Card>

  <Card title="Execute AI-generated code" icon="code" href="/tutorials/code-execution">
    Learn to use CodeBox for safe code execution — auto-install packages, run untrusted code, and capture output.
  </Card>

  <Card title="Python SDK Reference" icon="book" href="/reference/python/index">
    Complete API reference for SimpleBox, CodeBox, BrowserBox, ComputerBox, and more.
  </Card>
</CardGroup>
