Skip to main content

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 configured httpx.AsyncClient.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

superagent_ai-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

superagent_ai-0.0.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file superagent_ai-0.0.2.tar.gz.

File metadata

  • Download URL: superagent_ai-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for superagent_ai-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f7bf8208de10ffb59a52c1c0a140064a55d6254ba898246ca258cb5db164abf1
MD5 aff0c3b1381699a0236aa9ae22c89ac9
BLAKE2b-256 93b36aeda90f88f309e3c7e184d00e3ca90079b0deeeba77204ab2ea7cac6fc1

See more details on using hashes here.

File details

Details for the file superagent_ai-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: superagent_ai-0.0.2-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

Hashes for superagent_ai-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 511d79bc59004e30b0f7e84b632062616df821aa452738dbc7f05859025356f2
MD5 c1ba4d1a2d92f8c9197aeff096ac068d
BLAKE2b-256 d02ae69cbf5d5f0d72daf1a4875b5c007d259513e8a4085e9af62f9a9d40b2fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page