Python client for the AIORNOT API - detect AI-generated content in images, videos, audio, and text.
Project description
AIORNOT Python Client
Python client for the AIORNOT API - detect AI-generated content in images, videos, audio, and text.
Features
- Image Analysis: Detect AI-generated images, deepfakes, NSFW content, and more
- Video Analysis: Analyze videos for AI-generated content, synthetic voices, and deepfakes
- Voice Analysis: Detect AI-generated speech
- Music Analysis: Detect AI-generated music
- Text Analysis: Detect AI-generated text with block-level annotations
- Batch Processing: Process multiple files concurrently with progress tracking
- Sync & Async: Both synchronous and asynchronous clients available
Installation
# As a CLI tool (no install needed)
uvx aiornot --help
# As a library dependency
uv add aiornot # or: pip install aiornot
Requires Python 3.10+.
API Key Setup
Register for an account at AIORNOT and get your API key from your dashboard.
Click Create New Token to open the dialog:
Copy your token after creating it.
[!WARNING] Never share your API key with anyone. It is like a password.
CLI Usage
Token Management
Configure your API key (saved to ~/.aiornot/config.json):
aiornot token config
Verify your token is valid:
aiornot token check
Alternatively, set an environment variable:
export AIORNOT_API_KEY=your_api_key
Analyzing Files
# Analyze an image
aiornot image photo.jpg
# Analyze a video
aiornot video clip.mp4
# Analyze voice/speech audio
aiornot voice speech.mp3
# Analyze music
aiornot music song.wav
# Analyze text (direct input or from file)
aiornot text "Some text to analyze"
aiornot text --file document.txt
Output Formats
# JSON output (default)
aiornot image photo.jpg --format json
# Human-readable table
aiornot image photo.jpg --format table
# Minimal (verdict + confidence)
aiornot image photo.jpg --format minimal
# Just the verdict
aiornot image photo.jpg --quiet
Analysis Filtering
# Only run specific analyses
aiornot image photo.jpg --only ai_generated --only deepfake
# Exclude analyses
aiornot image photo.jpg --excluding nsfw --excluding quality
Batch Processing
Process multiple files with JSONL output:
# Process multiple files
aiornot batch image photo1.jpg photo2.png photo3.webp
# Process a directory
aiornot batch image --dir ./photos
aiornot batch image --dir ./photos --recursive
# Process from CSV file
aiornot batch image --csv files.csv --key image_path
aiornot batch image --csv files.csv --key filename --base-dir /data/images
# Output options
aiornot batch image --dir ./photos --output results.jsonl # Write to file
aiornot batch image --dir ./photos --format summary # Summary only
aiornot batch image --dir ./photos --format quiet # Exit code only
# Control concurrency and progress
aiornot batch image --dir ./photos --concurrency 10 --progress
aiornot batch image --dir ./photos --fail-fast # Stop on first error
Available batch commands: image, video, voice, music, text
JSONL output format (one JSON object per line):
{"status":"success","input":"photo1.jpg","result":{...}}
{"status":"error","input":"photo2.jpg","error":"FileNotFound","message":"..."}
{"status":"summary","total":2,"succeeded":1,"failed":1,"success_rate":0.5}
Python Library Usage
Quick Start
from aiornot import Client
# Uses AIORNOT_API_KEY env var or ~/.aiornot/config.json
client = Client()
# Or pass explicitly
client = Client(api_key="your_api_key")
# Analyze an image
resp = client.image_report_from_file("path/to/image.jpg")
print(f"Verdict: {resp.verdict}") # "ai" or "human"
print(f"Confidence: {resp.confidence}") # 0.0 to 1.0
print(f"Is AI: {resp.is_ai()}") # True or False
# Analyze text
resp = client.text_report("Some text to analyze for AI generation.")
print(f"Is AI: {resp.is_ai()}")
# Analyze voice audio
resp = client.voice_report_from_file("path/to/speech.mp3")
print(f"Verdict: {resp.verdict}")
# Analyze music
resp = client.music_report_from_file("path/to/song.mp3")
print(f"Verdict: {resp.verdict}")
# Analyze video
resp = client.video_report_from_file("path/to/video.mp4")
print(f"AI Video: {resp.ai_video_detected}")
print(f"AI Voice: {resp.ai_voice_detected}")
Async Client
import asyncio
from aiornot import AsyncClient
async def main():
client = AsyncClient()
# All methods are async
resp = await client.image_report_from_file("image.jpg")
print(f"Verdict: {resp.verdict}")
asyncio.run(main())
Image Analysis
Control which analyses to run using only or excluding:
from aiornot import Client, ImageAnalysisType
client = Client()
# Only run AI detection and deepfake analysis
resp = client.image_report_from_file(
"image.jpg",
only=[ImageAnalysisType.AI_GENERATED, ImageAnalysisType.DEEPFAKE]
)
# Run all except NSFW detection
resp = client.image_report_from_file(
"image.jpg",
excluding=[ImageAnalysisType.NSFW]
)
# Access results
print(f"AI Generated: {resp.is_ai()}")
print(f"Deepfake: {resp.is_deepfake()}")
print(f"NSFW: {resp.is_nsfw()}")
# Generator detection (if AI detected)
if resp.report.ai_generated and resp.report.ai_generated.generator:
gen = resp.report.ai_generated.generator
print(f"Midjourney confidence: {gen.midjourney.confidence}")
Available ImageAnalysisType values:
AI_GENERATED- AI image detectionDEEPFAKE- Face manipulation detectionNSFW- Adult content detectionQUALITY- Image quality assessmentREVERSE_SEARCH- Reverse image search
Video Analysis
from aiornot import Client, VideoAnalysisType
client = Client()
resp = client.video_report_from_file(
"video.mp4",
only=[VideoAnalysisType.AI_VIDEO, VideoAnalysisType.DEEPFAKE_VIDEO]
)
print(f"AI Video: {resp.ai_video_detected} ({resp.ai_video_confidence:.1%})")
print(f"AI Voice: {resp.ai_voice_detected}")
print(f"AI Music: {resp.ai_music_detected}")
print(f"Deepfake: {resp.deepfake_detected}")
Available VideoAnalysisType values:
AI_VIDEO- AI-generated video detectionAI_VOICE- Synthetic voice detectionAI_MUSIC- AI-generated music detectionDEEPFAKE_VIDEO- Deepfake detection
Text Analysis
client = Client()
# Basic text analysis
resp = client.text_report("Text to analyze...")
print(f"Is AI: {resp.is_ai()}")
print(f"Confidence: {resp.confidence}")
# With block-level annotations
resp = client.text_report(
"First paragraph here. Second paragraph here.",
include_annotations=True
)
for block, confidence in resp.annotations:
print(f"[{confidence:.1%}] {block[:50]}...")
Batch Processing
Process multiple files concurrently:
from pathlib import Path
from aiornot import Client
client = Client()
# Process multiple images
images = list(Path("images").glob("*.jpg"))
results = client.image_report_batch(
images,
max_concurrency=5,
on_progress=lambda done, total: print(f"{done}/{total}")
)
print(f"Total: {results.total}")
print(f"Succeeded: {results.succeeded}")
print(f"Failed: {results.failed}")
print(f"Success rate: {results.success_rate:.1%}")
# Access individual results
for result in results.results:
if result.success:
print(f"{result.input}: {result.result.verdict}")
else:
print(f"{result.input}: Error - {result.error}")
# Process a directory
results = client.image_report_directory(
"path/to/images",
recursive=True,
max_concurrency=5
)
# Process from CSV
results = client.image_report_from_csv(
"files.csv",
key="file_path",
base_directory="/data/images"
)
Error Handling
from aiornot import Client
from aiornot.exceptions import (
AIORNotAuthenticationError,
AIORNotValidationError,
AIORNotRateLimitError,
AIORNotTimeoutError,
)
client = Client()
try:
resp = client.image_report_from_file("image.jpg")
except AIORNotAuthenticationError:
print("Invalid API key")
except AIORNotValidationError as e:
print(f"Invalid input: {e}")
except AIORNotRateLimitError:
print("Rate limit exceeded")
except AIORNotTimeoutError:
print("Request timed out")
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiornot-0.1.0.tar.gz.
File metadata
- Download URL: aiornot-0.1.0.tar.gz
- Upload date:
- Size: 283.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bd33da8bb4c1caae738f2b94a1027f0a0cf69014e32bb189d2fe477ef61f784
|
|
| MD5 |
5ce10fe0b6961b638c106273726ccafb
|
|
| BLAKE2b-256 |
49dd6ba026cd080ea7198d52a0457e509cf4634918f01dbfadc7642a01887307
|
File details
Details for the file aiornot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiornot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e834e3b962f9db59ce46f52d901fa16b8516ea33f16a75c55490003019acb39
|
|
| MD5 |
48055f23b5ea27fbfbda8c0cc384c124
|
|
| BLAKE2b-256 |
702c818e368889fdf4fc1d0f11a519c961a0dba367d939a8609c652e676d421c
|