Skip to main content

Python SDK for the Authenta API to detect deepfakes and manipulated media

Project description

Authenta Python SDK

Python client for the Authenta API to detect deepfakes and manipulated media using image and video models.

Installation

Follow the steps below to install the authenta package.

Install from PyPI

pip install authenta

(Optional) Local development

git clone https://github.com/phospheneai/authenta-python-sdk.git
cd authenta-python-sdk
pip install -e .

Basic functionalities and workflows

The package provides basic functionalities for:

  • Uploading images and videos to Authenta
  • Running deepfake / AI-generated content detection
  • Polling for results and retrieving detection outputs
  • Listing and deleting media records via the /media endpoints

1. Quick detection workflow

from authenta import AuthentaClient

client = AuthentaClient(
    base_url="https://platform.authenta.ai/api",  # platform base: https://platform.authenta.ai 
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

# Upload a file and wait for processing to finish
media = client.process("samples/nano_img.png", model_type="AC-1")
print("Status:", media["status"])
print("Fake:", media.get("fake"))
print("Result URL:", media.get("resultURL"))
print("Heatmap URL:", media.get("heatmapURL"))

2. Two-step upload and polling

from authenta import AuthentaClient

client = AuthentaClient(
    base_url="https://platform.authenta.ai/api",
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

# 1) Upload only
upload_meta = client.upload_file("samples/nano_img.png", model_type="AC-1")
mid = upload_meta["mid"]

# 2) Poll later using the media id
final_media = client.wait_for_media(mid)
print(final_media["status"], final_media.get("fake"))

Model types and usage

Authenta exposes different detection models that you select via the model_type parameter.

Model type Modality Description
AC-1 Image Detects AI-generated or manipulated images.
DF-1 Video Detects deepfake or manipulated faces in video content.

Detect AI-generated images (AC-1)

from authenta import AuthentaClient

client = AuthentaClient(
    base_url="https://platform.authenta.ai/api",
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

media = client.upload_file("samples/nano_img.png", model_type="AC-1")
print(media["mid"], media["status"])

Detect deepfake videos (DF-1)

from authenta import AuthentaClient

client = AuthentaClient(
    base_url="https://platform.authenta.ai/api",
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

media = client.upload_file("samples/video.mp4", model_type="DF-1")
print(media["mid"], media["status"])

Visualizing results

The SDK provides helpers in authenta.visualization to save heatmaps and videos with bounding boxes to your local disk.

Save heatmap (image or video)

from authenta.visualization import save_heatmap

# For AC-1 (image): saves a heatmap image (e.g. JPG/PNG)
media = client.process("examples/image.jpg", model_type="AC-1")
save_heatmap(
    media,
    out_path="results/image_heatmap.jpg",
    participant_id=0,
    model_type="AC-1",
)

# For DF-1 (video): saves a heatmap video (e.g. MP4)
media = client.process("examples/video.mp4", model_type="DF-1")
save_heatmap(
    media,
    out_path="results/video_heatmap.mp4",
    participant_id=0,
    model_type="DF-1",
)

Save video with bounding boxes (DF-1)

from authenta.visualization import save_bounding_box_video

media = client.process("examples/video.mp4", model_type="DF-1")

save_bounding_box_video(
    media,
    src_video_path="examples/video.mp4",              # original input
    out_video_path="results/video_bboxes.mp4",       # output with boxes
    participant_id=0,
)

This function downloads the detailed JSON at media["resultURL"], converts the per-frame boundingBoxes into a sequence, and uses OpenCV to draw bounding boxes over each frame before writing a new MP4 file.

Method reference

AuthentaClient

The main entrypoint for interacting with the Authenta API.

Initialization

from authenta import AuthentaClient

client = AuthentaClient(
    base_url="https://platform.authenta.ai/api",
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)
  • base_url: str – Authenta API base URL (e.g. https://platform.authenta.ai/api).
  • client_id: str – Your Authenta client ID.
  • client_secret: str – Your Authenta client secret.

upload_file(path: str, model_type: str) -> Dict[str, Any]

  • Creates a media record via POST /media and uploads the file to the returned presigned URL.
  • Returns media JSON including fields such as mid, status, modelType, and timestamps.

wait_for_media(mid: str, interval: float = 5.0, timeout: float = 600.0) -> Dict[str, Any]

  • Polls GET /media/{mid} until the status is PROCESSED, FAILED, or ERROR.
  • Sleeps interval seconds between polls and raises TimeoutError if timeout is exceeded.

process(path: str, model_type: str, interval: float = 5.0, timeout: float = 600.0) -> Dict[str, Any]

  • High-level helper that runs upload_file followed by wait_for_media.
  • Returns the final processed media JSON, including detection outputs like fake, resultURL, heatmapURL, and scores (when available).

get_media(mid: str) -> Dict[str, Any]

  • Fetches the current state of a media record via GET /media/{mid}.
  • Returns the parsed JSON media object.

list_media(**params) -> Dict[str, Any]

  • Lists media records for the client using GET /media.
  • Supports optional query parameters such as page, pageSize, or status (depending on API support).

delete_media(mid: str) -> None

  • Deletes a media record via DELETE /media/{mid}.
  • Raises an HTTP error if the request fails.

View source on GitHub

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

authenta-0.2.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

authenta-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file authenta-0.2.0.tar.gz.

File metadata

  • Download URL: authenta-0.2.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for authenta-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d7ecea0bee7e750aec3b9cd3105ba93f22e66d787f6a9eed3f0f7984ae624fd0
MD5 1ee7d777b65bfc9e06bf71f6e66e3059
BLAKE2b-256 1c9138ed02c726b04e88ef415804a98ce0e22b6e37bde1e4113814a25dcded12

See more details on using hashes here.

File details

Details for the file authenta-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: authenta-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for authenta-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e933ecab215cba0605c50e6d09cf49fbd02f036b59dd8e2825322f0d4d6a933
MD5 1a0e47900995526c3ba64dcda6789baf
BLAKE2b-256 54d32629571e6e8cbec4fc17844efacf1640c16b2d437d06b182a98021304bc9

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