Skip to main content

TruthScan Image Detection — Python Client

Official Python client for the TruthScan AI Image Detection API. Detect whether images are AI-generated, real, digitally edited, or AI-edited.

Requirements

Installation

pip install truthscan-image-detector-client

Quick start

import os

from truthscan.image_detection import ImageDetectionClient

api_key = os.environ.get("TRUTHSCAN_API_KEY", "your_api_key_here")
client = ImageDetectionClient(api_key=api_key)

result = client.detect("path/to/image.jpg")

print(f"Status: {result['status']}")
print(f"Score: {result.get('result', 'N/A')}")
print(f"Final: {(result.get('result_details') or {}).get('final_result', '')}")

How it works

ImageDetectionClient.detect() runs the full workflow for you:

  1. Presign — request a presigned upload URL for the image filename
  2. Upload — upload the image bytes to storage
  3. Detect — submit the image for analysis and receive a detection ID
  4. Poll — call the query endpoint until status is done (or timeout)

You only need one method call; polling interval and max attempts are configurable on detect().

Send a request and poll manually

For step-by-step control, use ImageDetectionService:

from truthscan.image_detection import ImageDetectionService

service = ImageDetectionService(
    base_url="https://ai-image-detect.undetectable.ai",
    api_key=api_key,
)

presign = service.get_presigned_url("photo.jpg")
service.upload(presign["presigned_url"], "path/to/photo.jpg")

file_url = ImageDetectionService.build_detect_file_url(
    presign["file_path"], presign["presigned_url"]
)
detect = service.detect(file_url)

result = service.poll_for_result(detect["id"], max_attempts=60, sleep_seconds=0.5)
print(result["status"], result.get("result_details"))

Configuration

from truthscan.image_detection import ImageDetectionClient, DefaultConsoleLogger

client = ImageDetectionClient(
    api_key="YOUR_API_KEY",
    base_url=None,
    timeout=60,
    logger=DefaultConsoleLogger("info"),
)

API reference

ImageDetectionClient

Method Description
detect(image, email?, generate_preview?, max_poll_attempts?, poll_interval_seconds?) Full workflow: presign, upload, detect, poll. Returns DetectionResult.
check_user_credits() Returns credit balance for the API key.

Supported file formats

JPG, JPEG, PNG, WebP, JFIF, HEIC, HEIF, AVIF, BMP, TIFF, TIF, GIF, SVG, PDF

File size limits: 1 KB – 10 MB

Note: Remove spaces from filenames before uploading.

Development

cd python
pip install -e .
python tests/test_client.py

License

MIT

Metadata

Release files for truthscan-image-detector-client 20260709.0.0

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

Source distribution (sdist)

Source distribution for truthscan-image-detector-client 20260709.0.0
File Size Uploaded Provenance
truthscan_image_detector_client-20260709.0.0.tar.gz 11.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for truthscan-image-detector-client 20260709.0.0
File Interpreter ABI Platform
truthscan_image_detector_client-20260709.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / truthscan_image_detector_client-20260709.0.0.tar.gz

Download URL truthscan_image_detector_client-20260709.0.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0edf88fb7ad09aa246989e2b22371152d98b7d1e6b51f5771257c52029680488
BLAKE2b-256 checksum
How to use checksums
809a35e39b4b08f6f5a69f87125824a865a434f95d04c874112ad02dfa30fd35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / truthscan_image_detector_client-20260709.0.0-py3-none-any.whl

Download URL truthscan_image_detector_client-20260709.0.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8d4722e7603f188878b2b7c5fad6195b8373c47a728e0961d4c009e33efae5d
BLAKE2b-256 checksum
How to use checksums
00a19cc057b0839bf192a1ec8800db9421de59e3221298e11efa54ad98f8d2f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for truthscan-image-detector-client 20260709.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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