Skip to main content

Guard Logo
Guard

A Python client for seamlessly integrating visual safety filters into your applications

Release License: Apache 2.0 PRs Welcome

Features

🛡️ Multi-Layered Content Moderation: Automatically detects AI-generated, violent, and explicit content in images and videos.

🔄️ Two Engines, One Result Shape: Use the cloud API for maximum accuracy, or the optional on-device engine to build and test locally without an API key. Both return the exact same strictly typed models.

⚡ Sync & Async Support: Natively supports both synchronous operations and async/await out of the box, making it a perfect fit for high-performance frameworks like FastAPI.

🛠️ Comprehensive API Bindings: Typed bindings for the entire API including spaces, predictions, targets, predictors, runners, shares, and reactions. We also include token estimation, so you can price a job before you spend on it.

Installation

You can install the client in two ways, depending on whether you want to rely purely on the cloud API or include the local fallback engine.

Cloud-Only (Standard)

Installs the lightweight client. All media detection is routed to the Elhio Cloud API. This version is entirely Apache 2.0 licensed.

pip install guard-client

Cloud + Local (Hybrid)

Installs the client along with the guard-local-detector engine. This allows you to process local file paths directly on your hardware with zero network latency. Note: The local engine dependency is licensed under the AGPL-3.0.

pip install "guard-client[local]"

Quick Start

The analyze() method runs the entire detection lifecycle for you. It creates a prediction, uploads the media, confirms the upload, polls until processing finishes, and returns the result.

You will need an API key and a space to create the prediction in. You can create a new access token in the Elhio dashboard (under Settings > Account Settings > Access Tokens). If you do not know your space ID yet, you can ask the API for it. The spaces.list() method returns every space the key can see.

from guard_client import GuardClient

with GuardClient(api_key="your_api_key_here") as client:
    # 1. Get an available space
    space = client.spaces.list()[0]

    # 2. Analyze the media (creates prediction, uploads, and polls for results)
    result = client.analyze("photo.jpg", space_id=space.id)

    # 3. Print the detection results
    for item in result.results:
        print(f"{item.label}: {item.score}/100")

# AI-Generated: 87/100
# Violent: 2/100
# Explicit: 1/100

Both values also resolve from the environment, so the common case needs no arguments at all:

# With GUARD_API_KEY and GUARD_SPACE_ID set (environment or .env)
with GuardClient() as client:
    result = client.analyze("photo.jpg")

The analyze() method accepts a file path, raw bytes, or an open binary file object. The media type is detected automatically from the filename or the file's magic bytes. You can pass media_type= to skip this automatic detection.

Local Detection

With the [local] extra installed, you can pass engine="local" to run entirely on-device. This requires no network calls, no API key, and no space ID. Results use the exact same DetectionResult type as the cloud API, so the code reading them does not need to change.

Local detection is opt-in and never automatic. The engine you get is the engine you explicitly ask for, regardless of which extras happen to be installed.

from guard_client import GuardClient

with GuardClient(engine="local") as client:
    # 1. Analyze the media
    result = client.analyze("/local/path/to/video.mp4")
    
    # 2. Print the detection results
    for item in result.results:
        print(f"{item.label}: {item.score}/100")

# AI-Generated: 90/100
# Violent: 2/100
# Explicit: 1/100

Two fields easily tell the engines apart. The result.prediction_id is None because a local run creates nothing server-side, meaning there is nothing to share or react to. The result.detected field carries the engine's own per-category threshold verdict, which the cloud API does not report. Reading it means you are opting into extra detail, not into a different data shape.

Development

This project uses uv for package and environment management. A single uv sync creates the .venv, reads uv.lock, and installs everything exactly as it was locked. The test suite is fully mocked, so there is no API key to obtain and no network access at any point.

# set up the environment
uv sync

# run tests
uv run pytest

# build for production
uv build

The Contributing Guide covers the rest: linting and type checking, the documentation build, working against the optional local engine and its shared contract suite, and testing end-to-end against a live API.

Contributing

We welcome contributions! Please note that all contributors must sign our automated CLA. Read more in our Contributing Guide.

License

This repository and its corresponding PyPI package are licensed under the Apache v2.0 (Apache-2.0) - see the LICENSE file for details.

Metadata

Release files for guard-client 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for guard-client 0.0.2
File Size Uploaded Provenance
guard_client-0.0.2.tar.gz 261.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for guard-client 0.0.2
File Interpreter ABI Platform
guard_client-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 353.2 kB

Release files / guard_client-0.0.2.tar.gz

Download URL guard_client-0.0.2.tar.gz
Size 261.0 kB
Tags Source
SHA-256 checksum
How to use checksums
105dd3669196ef6cab87a901126bff4a9db3fac5b36c0344d68ed9bf1380d50d
BLAKE2b-256 checksum
How to use checksums
08d0d7ae6bb2bfa6d65e1a4ba8bf96f4d134c32cb5ddff22d7de57b1d2034a56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / guard_client-0.0.2-py3-none-any.whl

Download URL guard_client-0.0.2-py3-none-any.whl
Size 92.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e992eedea6bb1db54742be97ec72f340bd28611eea08bbe5e515b1224bbdd49
BLAKE2b-256 checksum
How to use checksums
83de928f59de8c4f22b3a57a1cb9bcfee1f6db11a158b2685cc00b6254d1c7cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for guard-client 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for guard_client-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page