DEV Community

Muhammad Hamayo
Muhammad Hamayo

Posted on • Originally published at truthlensbyai.online

Building a Deepfake Detection API with Python and TruthLens

Why Every App Needs Deepfake Detection in 2026

Deepfakes are everywhere. From fake celebrity endorsements to AI-generated scam profiles, synthetic media is a $4B problem. If you build apps that handle user-uploaded images, you need deepfake detection.

The TruthLens API

TruthLens provides a simple REST API for detecting AI-generated images. Here is how to integrate it in 5 minutes.

Quick Start with Python

import requests

API_KEY = "your_truthlens_api_key"
API_URL = "https://truthlensbyai.online/api/detect"

def check_image(image_path):
    with open(image_path, "rb") as f:
        response = requests.post(
            API_URL,
            headers={"Authorization": f"Bearer {API_KEY}"},
            files={"image": f}
        )
    result = response.json()

    if result["is_ai_generated"]:
        print(f"AI Generated! Confidence: {result["confidence"]}")
    else:
        print("Looks authentic.")

    return result

# Check a suspicious image
result = check_image("suspicious_photo.jpg")
Enter fullscreen mode Exit fullscreen mode

Integration Examples

Flask Middleware

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route("/upload", methods=["POST"])
def upload():
    image = request.files["image"]
    # Check with TruthLens before accepting
    result = check_image_bytes(image.read())
    if result.get("is_ai_generated") and result["confidence"] > 0.8:
        return jsonify({"error": "AI-generated images not allowed"}), 400
    # Process normally
    return jsonify({"status": "accepted"})
Enter fullscreen mode Exit fullscreen mode

Content Moderation Pipeline

Use TruthLens as part of your moderation stack:

  1. User uploads image
  2. TruthLens API checks authenticity
  3. Flag high-confidence AI images for review
  4. Auto-reject obvious deepfakes
  5. Log results for audit trail

Pricing

Plan Detections/mo Price
Free 50 $0
Pro 5,000 $29/mo
Business Unlimited $99/mo

Get Your API Key

  1. Sign up at truthlensbyai.online
  2. Go to Dashboard
  3. Copy your API key
  4. Start detecting!

Have questions about integration? Drop them in the comments or check our API docs.

Top comments (0)