Skip to main content

Python SDK for Superagent.

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_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.

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.8.tar.gz (8.2 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.8-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: superagent_ai-0.0.8.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.2

File hashes

Hashes for superagent_ai-0.0.8.tar.gz
Algorithm Hash digest
SHA256 bc42c1c54b1c001cd154aea4e7696883af928b0a112b82c47b744420edb561a4
MD5 bafa8ca12ee709001d7d58287321d1c2
BLAKE2b-256 f5f33dee33ccbea76537f26733be8053a1f93b655c95b97308cbf3cec6697d75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for superagent_ai-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1132ba41cfff5d12c64e477a3f984f4cbdc94d1266896c15104f0626e30f4d31
MD5 fed9b399f5515310b45ed0beed5fbade
BLAKE2b-256 57259eb9be4eeef1ccb3823e42deb1b93b07dbc2dca02d74d7740e792fbfbaed

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