Skip to main content

Official Python SDK for the Raid AI detection API — detect AI-generated and manipulated media, and fact-check claims.

Project description

raidxai

Official Python SDK for the Raid AI detection API — detect AI-generated and manipulated media (images, audio, video) and fact-check media against the public record.

Sync and async clients, Python 3.10+. Full API reference: https://docs.raidxai.com.

Install

pip install raidxai

Authentication

Every request uses a developer token. Create one in the Raid AI dashboard (Settings → API keys) and keep it server-side — never ship it in client code.

from raidxai import RaidClient, FileInput

raid = RaidClient(
    api_key="<your-api-key>",                 # or os.environ["RAID_API_KEY"]
    base_url="<raid-ai-api-url>",             # required — or os.environ["RAID_API_BASE_URL"]
    # timeout=60.0,
    # max_retries=2,
    # auth_header="bearer",                   # or "x-api-key"
)

Each API key carries scopes (image, audio, video, fact-check) — a call to a modality your key isn't scoped for raises RaidApiError with a 403 (api_key.scope_missing).

Usage

Images (synchronous)

res = raid.images.process(FileInput.from_path("suspect.jpg"))
print(res.images[0].verdict, res.images[0].confidence)

# …or from a URL:
raid.images.process_from_url("https://example.com/photo.jpg")

Audio (synchronous)

from raidxai import VoiceWorkflow

res = raid.audio.process(
    FileInput.from_path("clip.mp3"),
    workflow_type=VoiceWorkflow.AI_DETECTION_ONLY,
)
print(res.is_ai_detected, res.detection_confidence)

Video (asynchronous — submit then poll)

# One call: submit and wait for the terminal verdict.
job = raid.video.submit_and_wait(
    FileInput.from_path("clip.mp4"),
    client_duration_seconds=42,
    interval_seconds=3,
    timeout_seconds=300,
)
print(job.status, job.result.verdict if job.result else None)

# …or drive it yourself:
submitted = raid.video.submit(FileInput.from_path("clip.mp4"), client_duration_seconds=42)
state = raid.video.get_job(submitted.job_id)

Fact-checking (asynchronous)

job = raid.fact_checking.submit_and_wait(
    FileInput.from_path("photo.jpg"),
    "image",
    user_context="Claimed to be from the 2024 election.",
)
print(job.result.summary if job.result else None)

Async

Every resource has an async twin on AsyncRaidClient with the same method names:

import asyncio
from raidxai import AsyncRaidClient, FileInput

async def main():
    async with AsyncRaidClient(api_key="<your-api-key>") as raid:
        res = await raid.images.process(FileInput.from_path("photo.jpg"))
        print(res.images[0].verdict)

asyncio.run(main())

Errors

Non-2xx responses raise RaidApiError (.status, .code, .message, .body, plus .is_auth / .is_payment_required / .is_rate_limited). Transient 429/5xx responses are retried automatically with exponential backoff (max_retries). A submit_and_wait that never finishes raises RaidTimeoutError.

from raidxai import RaidApiError, RaidTimeoutError

try:
    raid.images.process(file)
except RaidApiError as err:
    if err.is_auth:
        print("bad or unscoped token:", err.code)
    elif err.is_payment_required:
        print("out of credits:", err.code)
    else:
        print(err.status, err.code, err.message)
except RaidTimeoutError as err:
    print("job did not finish in time; last status:", err.last_status)

Types

Response models are Pydantic v2 classes generated from the API's OpenAPI spec (ImageForensicsResponse, VideoJob, Verdict, JobStatus, …), so attributes are snake_case and tracked against the server contract.

Development

uv venv --python 3.12 && source .venv/bin/activate
uv pip install -e ".[dev]"
./scripts/generate.sh   # regenerate src/raidxai/_generated/models.py from ../spec/openapi.yaml
ruff check .
pytest

Run the live smoke test against a real tier (auto-skips without the key):

RAID_API_KEY=<your-api-key> RAID_API_BASE_URL=<raid-ai-api-url> pytest tests/test_live_smoke.py

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

raidxai-0.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

raidxai-0.1.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file raidxai-0.1.0.tar.gz.

File metadata

  • Download URL: raidxai-0.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for raidxai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba923b63efb457c7dcff08d177f2f8beb51829562204a33fbe911d79ed4e95b7
MD5 4acfc2b913250b432f600039957f70be
BLAKE2b-256 377f17eef77c4202d3ad60d697260f0bc5a41333d8e240395e201d0572eaea63

See more details on using hashes here.

Provenance

The following attestation bundles were made for raidxai-0.1.0.tar.gz:

Publisher: release.yml on Raid-AI-Corporation/Raid-AI-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file raidxai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: raidxai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for raidxai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9991baa0f089e5a3386b7224c839028a2d1c9f6c72bb46670c4dc2bc3ea189d3
MD5 6ee890cd960faa824ea5096da388219b
BLAKE2b-256 9fccebe6b6d77b5201e125171c6f91b2ea2999b00abca52c8dacacc7f300b290

See more details on using hashes here.

Provenance

The following attestation bundles were made for raidxai-0.1.0-py3-none-any.whl:

Publisher: release.yml on Raid-AI-Corporation/Raid-AI-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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