Python SDK for the Superagent Guard service.
Project description
Superagent Guard Python SDK
Python client for sending commands to the Superagent Guard endpoint.
Installation
pip install superagent-ai
Local development with uv
From the repository root, install the package (including test extras) and create a managed virtual environment:
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:
uv run pytest tests
Quick start
import asyncio
from superagent_guard 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.data.classification)
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 configuredhttpx.AsyncClient.
The returned GuardResult includes both the raw analysis payload from the Guard endpoint and the parsed classification for straightforward policy enforcement.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superagent_ai-0.0.4.tar.gz.
File metadata
- Download URL: superagent_ai-0.0.4.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51aaaee990e620dce555771506141889c9f20305e787a2223279e9b79213c945
|
|
| MD5 |
423e225025a561301032a7d6ef3d4c8e
|
|
| BLAKE2b-256 |
c48627aacf3715b8540a6f8129d8bf868581148ed3502e90ede8da4df1abfffc
|
File details
Details for the file superagent_ai-0.0.4-py3-none-any.whl.
File metadata
- Download URL: superagent_ai-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3105329b130c8e5f810f350bfd00749b5ea7202a54732f434d6c47d8a95e147
|
|
| MD5 |
9b81d0b829a402ce7d05634aff0407dd
|
|
| BLAKE2b-256 |
56a514b8b77b1408b6ba14761a379dd7bbc320c3123e10b7db0c21414abd62df
|