Metadata-Version: 2.4
Name: superagent-ai
Version: 0.0.8
Summary: Python SDK for Superagent.
Author: Superagent
License: MIT
Keywords: superagent,guard,sdk,safety
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx<0.28,>=0.25
Provides-Extra: tests
Requires-Dist: pytest>=7.4; extra == "tests"
Requires-Dist: pytest-asyncio>=0.23; extra == "tests"

# Superagent Guard Python SDK

Python client for sending commands to the Superagent Guard endpoint.

## Installation

```bash
pip install superagent-ai
```

## Local development with uv

From the repository root, install the package (including test extras) and create a managed virtual environment:

```bash
cd guard/python
uv sync --extra tests
```

This will provision `.venv`, install the SDK in editable mode, and pull in the testing dependencies. Once synced, run the test suite with:

```bash
uv run pytest tests
```

## Quick start

```python
import asyncio
from superagent_ai import create_guard

async def main() -> None:
    guard = create_guard(
        api_base_url="https://example.com/api/guard",
        api_key="sk-...",
    )

    result = await guard(
        "Generate a friendly greeting",
        on_block=lambda reason: print("Guard blocked:", reason),
        on_pass=lambda: print("Guard passed"),
    )

    if result.rejected:
        print("Rejected with:", result.reasoning)
    else:
        print("Approved", result.decision)

    await guard.aclose()

asyncio.run(main())
```

### Options

- `api_base_url` – fully qualified URL for your Guard endpoint.
- `api_key` – API key provisioned in Superagent.
- `timeout` – optional request timeout (defaults to 10 seconds).
- `client` – optionally provide your own configured `httpx.AsyncClient`.

The returned `GuardResult` includes both the raw analysis payload from the Guard endpoint and the parsed decision for straightforward policy enforcement.
