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.1.tar.gz (15.7 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.1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: raidxai-0.1.1.tar.gz
  • Upload date:
  • Size: 15.7 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.1.tar.gz
Algorithm Hash digest
SHA256 6c18629a3e825ee54c65b09d9325877753987804737f028623349e887c9a970a
MD5 18d091662c2ec476fccf922307aef95d
BLAKE2b-256 dbdcb976ac049e64dce8fef634eca998f15e54e8b9ec89ed1e308dd8bc3294d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for raidxai-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: raidxai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb4986d679be181543b06072b77968eaff0abacdd249de6e626f30d6902f10b4
MD5 36a09254f973400df161e6f1a3bbf3c7
BLAKE2b-256 489df116f87fb102a61626cb8d6be5b916a2226985624d889a44d9fc02273af6

See more details on using hashes here.

Provenance

The following attestation bundles were made for raidxai-0.1.1-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