Skip to main content

Official Python SDK for Veri AI Deepfake Detection API

Project description

veri-sdk

Official Python SDK for the Veri AI Deepfake Detection API.

Installation

pip install veri-sdk

Quick Start

from veri import VeriClient

# Create a client with your API key
client = VeriClient(api_key="your-api-key-here")

# Detect an image
with open("image.jpg", "rb") as f:
    result = client.detect(f)

print(f"Prediction: {result.prediction}")
print(f"Is AI-generated: {result.is_fake}")
print(f"Confidence: {result.confidence:.1%}")

Usage Examples

Detect from File Path

from pathlib import Path
from veri import VeriClient

client = VeriClient(api_key="your-api-key")

result = client.detect(Path("suspicious-image.jpg"))

if result.is_fake:
    print("This image appears to be AI-generated")
    print(f"Confidence: {result.confidence:.1%}")
    print(f"Verdict: {result.verdict}")
else:
    print("This image appears to be authentic")

Detect from Bytes

import requests
from veri import VeriClient

client = VeriClient(api_key="your-api-key")

# Download image and detect
response = requests.get("https://example.com/image.jpg")
result = client.detect(response.content)

Detect from URL

result = client.detect_url("https://example.com/image.jpg")

With Detection Options

from veri import VeriClient, DetectionOptions

client = VeriClient(api_key="your-api-key")

options = DetectionOptions(
    threshold=0.6,
)

result = client.detect(image_bytes, options=options)

Get Profile

profile = client.get_profile()
print(f"User ID: {profile['userId']}")
print(f"Credits: {profile['credits']}")

Async Client

import asyncio
from veri import AsyncVeriClient

async def main():
    async with AsyncVeriClient(api_key="your-api-key") as client:
        # Run multiple detections concurrently
        tasks = [
            client.detect(image1_bytes),
            client.detect(image2_bytes),
            client.detect(image3_bytes),
        ]
        results = await asyncio.gather(*tasks)

        for i, result in enumerate(results):
            print(f"Image {i+1}: {'FAKE' if result.is_fake else 'REAL'}")

asyncio.run(main())

Error Handling

from veri import (
    VeriClient,
    VeriAPIError,
    VeriValidationError,
    VeriRateLimitError,
    VeriTimeoutError,
)

client = VeriClient(api_key="your-api-key")

try:
    result = client.detect(image_bytes)
except VeriRateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except VeriTimeoutError as e:
    print(f"Request timed out after {e.timeout_ms}ms")
except VeriAPIError as e:
    print(f"API Error: {e.message} (code: {e.code})")
    print(f"Request ID: {e.request_id}")
except VeriValidationError as e:
    print(f"Validation Error: {e.message} (field: {e.field})")

Configuration

client = VeriClient(
    api_key="your-api-key",
    base_url="https://api.veri.studio/v1",  # Custom API URL
    timeout=30.0,                         # Request timeout (seconds)
    max_retries=3,                        # Retry attempts
)

Context Manager

Both sync and async clients support context managers:

# Sync
with VeriClient(api_key="your-api-key") as client:
    result = client.detect(image_bytes)

# Async
async with AsyncVeriClient(api_key="your-api-key") as client:
    result = await client.detect(image_bytes)

Model

Model Description
veri_face DenseNet-121 + MoE face forgery detector

Type Hints

This SDK is fully typed. Import types for your IDE:

from veri import (
    DetectionResult,
    DetectionOptions,
    ModelResult,
)

Requirements

  • Python 3.10+
  • httpx
  • pydantic

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

veri_sdk-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

veri_sdk-0.1.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: veri_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for veri_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3f2c368f9c5df1102490533050395544655ddee96a597d20d8c986914d709408
MD5 18661c62e9f1f35c0aa9600684ffa50f
BLAKE2b-256 72c534b27f7a0bad62cc7f8b6043a3cb056548751e807263e8704047afdc8377

See more details on using hashes here.

File details

Details for the file veri_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: veri_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for veri_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ffb71a8c075887176095f7c8f10195fa9a2b555cb3bfe8aae56344896609cab4
MD5 4661013b8c0a5fa39e21441e673b1a37
BLAKE2b-256 dc3c3e9fffd0f0285b5c22821b9aa0f711ed520afe471491abfd7112ab0b4ada

See more details on using hashes here.

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