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

# Install and configure the AgentRail Python SDK client

> Add the agentrail package to your Python 3.10+ project, install from the local repo for pre-release work, and use the async context manager.

The AgentRail Python SDK (`agentrail`) is an async HTTP client for the Task Lifecycle API. It requires Python 3.10 or newer, uses `httpx` for transport, and exposes Pydantic v2 models for all request and response types.

## Install from PyPI

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

## Install from the local repository

If you need to work against the SDK before a package release, install it in editable mode from the repository source:

```bash theme={null}
pip install -e /path/to/agentrail/sdk/python
```

<Note>
  Editable installs (`-e`) reflect changes to the source immediately without reinstalling.
</Note>

## Use as an async context manager

The Python client manages an `httpx.AsyncClient` internally. Use it as an async context manager to ensure the connection pool is closed when your code finishes:

```python theme={null}
import asyncio
import os

from agentrail import AgentRailClient

async def main():
    async with AgentRailClient(
        base_url=os.getenv("AGENTRAIL_BASE_URL", "http://127.0.0.1:3000"),
        api_key=os.environ["AGENTRAIL_API_KEY"],
    ) as client:
        # Use client here
        ...

asyncio.run(main())
```

If you need the client to outlive a single `async with` block, you can call `await client.close()` manually instead.

## Model conventions

Python models expose `snake_case` attributes. All response models are validated Pydantic v2 objects. Request models also accept the API's camelCase aliases, but prefer `snake_case` in Python code.

## Next steps

* [Configure authentication](/docs/sdk/authentication) — set up your API key and base URL
* [Client methods](/docs/sdk/python/client) — list tasks, submit work, and ship
* [Stream events](/docs/sdk/python/events) — subscribe to real-time task lifecycle events
* [Verify webhooks](/docs/sdk/python/webhooks) — validate inbound webhook deliveries
