Developer Documentation

AI Image Detector API

A REST API that classifies images as AI-generated or authentic with 99.1% accuracy. It returns model attribution across 25+ generators and produces region-level heatmaps in under 100ms. The free tier covers 500 scans per month with no credit card.

<100ms
p50 latency
99.1%
accuracy
25+
generators detected
500/mo
free scans

Quickstart

Three steps from zero to your first verdict. The full walkthrough including SDK installation is in our 2-minute quickstart guide.

  1. 1

    Create an account

    Sign up with email. No credit card required. Your API key is available in the dashboard immediately.

  2. 2

    Install the SDK or use cURL

    Official SDKs in Python, Node.js, Go, Ruby, PHP, Java, and .NET. Or hit the REST API directly.

  3. 3

    POST your first image

    Send the image as a URL or as a base64-encoded payload. Get back a verdict in under 100ms.

cURLPOST /v1/detect
curl -X POST https://api.aiimagedetectorapi.com/v1/detect \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/photo.jpg",
    "include_attribution": true,
    "include_heatmap": true
  }'

Authentication

Every request requires a Bearer token in the Authorization header. API keys are scoped to a single project and can be rotated at any time from the dashboard.

HTTP HEADER
Authorization: Bearer aidet_live_sk_5d8f23ab...

Key types

  • Test keys use the aidet_test_* prefix and are for development.
  • Live keys use the aidet_live_* prefix for production.
  • Restricted keys can be scoped to specific endpoints on Pro and Enterprise.

Security

  • TLS 1.2+ required on all connections.
  • Keys are never logged in our systems.
  • IP allowlists are supported on Pro and above.
  • Hourly key rotation is supported via the API.

API Endpoints

Eight endpoints cover detection, batch, forensics, model attribution, and account utilities. Full reference at /docs/endpoints/.

MethodEndpointPurpose
POST/v1/detectSingle-image AI detection with attribution and heatmap
POST/v1/detect/batchUp to 100 images per request, returns array of verdicts
POST/v1/detect/asyncAsync batch with webhook callback (Pro and above)
POST/v1/forensicsPixel-level forensics. ELA, frequency analysis, noise residual
POST/v1/c2pa/verifyVerify Content Credentials manifest cryptographically
GET/v1/jobs/{id}Poll the status of an async batch job
GET/v1/usageCurrent period usage, quota remaining
GET/v1/healthService health and version info

Request and Response

Submit images by URL, by file upload (multipart), or as a base64 string. The response is JSON and stable across versions.

Request body

{
  "image_url": "https://example.com/photo.jpg",
  "include_attribution": true,
  "include_heatmap": true,
  "include_forensics": false,
  "model_threshold": 0.5,
  "metadata": { "user_id": "u_123", "context": "claim_4598" }
}

Response body

{
  "verdict": "ai_generated",
  "confidence": 0.978,
  "model_attribution": {
    "midjourney_v7": 0.84,
    "flux_pro": 0.09,
    "stable_diffusion_4": 0.05,
    "dalle_4": 0.02
  },
  "heatmap_url": "https://cdn.aiimagedetectorapi.com/h/8a3f....png",
  "c2pa_manifest_present": false,
  "metadata": { "user_id": "u_123", "context": "claim_4598" },
  "request_id": "req_01HXYZABC...",
  "latency_ms": 87
}

Stable contracts. We never remove fields from a v1 response. New fields may be added. Clients should ignore unknown keys.

Rate Limits

Limits are per-project, computed on a sliding 60-second window. Bursts up to 2x the rate are allowed for short periods.

PlanSustained RPSBurstConcurrent batches
Free2 req/s5 req/s1
Pro200 req/s400 req/s10
EnterpriseCustomCustomUnlimited

Response headers

X-RateLimit-Limit: 200
X-RateLimit-Remaining: 187
X-RateLimit-Reset: 1714780800
X-Request-Id: req_01HXYZABC...

When you exceed the limit, the API returns 429 Too Many Requests with a Retry-After header. Our SDKs implement automatic exponential backoff with jitter.

Error Handling

Errors return a consistent JSON shape. Always inspect both the HTTP status and the code field. The code is stable across versions. The message may change.

{
  "error": {
    "code": "image_too_large",
    "message": "Image exceeds 20 MB limit (got 24.3 MB)",
    "param": "image_url",
    "request_id": "req_01HXYZABC..."
  }
}
HTTPCodeMeaning
400invalid_requestMalformed body, missing field, or bad image URL
400image_too_largeFile exceeds 20 MB
400image_unsupported_formatOnly JPEG, PNG, WebP, HEIC, GIF, BMP, and TIFF are supported
401unauthorizedMissing or invalid API key
402payment_requiredSubscription expired or quota exhausted
403forbiddenKey lacks permission for this endpoint
404not_foundJob ID not found or unsupported endpoint
422image_unfetchableURL did not return a valid image (timeout, 4xx, 5xx)
429rate_limitedToo many requests. Honor Retry-After
500internal_errorTransient. Retry with backoff. Logged with request_id
503service_unavailableMaintenance or capacity issue. Status page link in response

Webhooks

For async batch jobs and high-volume detection pipelines, register a webhook URL and receive verdicts as they complete. Webhooks are signed with HMAC-SHA256.

Configure

Add a webhook URL in the dashboard or via the API. Each project supports up to 5 webhooks.

Verify

Every payload includes an X-Signature header. Verify with the shared secret before acting.

Retry

Failed deliveries retry 5 times with exponential backoff over 24 hours.

Event types

detection.completed, batch.completed, batch.failed

Verifying signatures (Node.js)

import crypto from "crypto";

function verify(rawBody, signature, secret) {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(rawBody)
    .digest("hex");
  return crypto.timingSafeEqual(
    Buffer.from(expected),
    Buffer.from(signature)
  );
}

SDKs and Libraries

Official SDKs are available in seven languages. All implement automatic retries, request signing, response parsing, and helpful error messages.

py

Python

pip install aiimagedetector github.com/aiimagedetector/python
JS

Node.js / TypeScript

npm install @aiimagedetector/node github.com/aiimagedetector/node
Go

Go

go get github.com/aiimagedetector/go github.com/aiimagedetector/go
Rb

Ruby

gem install aiimagedetector github.com/aiimagedetector/ruby
PHP

PHP

composer require aiimagedetector/php github.com/aiimagedetector/php
Jv

Java

implementation 'com.aiimagedetector:java:1.0' github.com/aiimagedetector/java
C#

.NET

dotnet add package AIImageDetector github.com/aiimagedetector/dotnet

Python example

PYTHON
from aiimagedetector import Client

client = Client(api_key="aidet_live_sk_...")

result = client.detect(
    image_url="https://example.com/photo.jpg",
    include_attribution=True,
    include_heatmap=True,
)

print(f"Verdict: {result.verdict} ({result.confidence:.0%})")
print(f"Most likely model: {result.top_model()}")
if result.heatmap_url:
    print(f"Heatmap: {result.heatmap_url}")

Node.js / TypeScript example

TYPESCRIPT
import { Client } from "@aiimagedetector/node";

const client = new Client({ apiKey: process.env.AIDET_KEY! });

const result = await client.detect({
  imageUrl: "https://example.com/photo.jpg",
  includeAttribution: true,
  includeHeatmap: true,
});

console.log(`Verdict: ${result.verdict} (${(result.confidence * 100).toFixed(1)}%)`);
console.log(`Top model: ${result.topModel()}`);

Go example

GO
package main

import (
  "fmt"
  "github.com/aiimagedetector/go"
)

func main() {
  client := aiimagedetector.NewClient("aidet_live_sk_...")

  result, err := client.Detect(&aiimagedetector.DetectRequest{
    ImageURL: "https://example.com/photo.jpg",
    IncludeAttribution: true,
  })
  if err != nil {
    panic(err)
  }

  fmt.Printf("Verdict: %s (%.1f%%)\n", result.Verdict, result.Confidence*100)
}

Best Practices

Send image URLs, not base64, when possible

URL-based requests are faster because we fetch in parallel and avoid the base64 inflation tax. Base64 is fine for ephemeral images you cannot host.

Use batch for more than 10 images

Single-image requests have per-call overhead. Batches up to 100 images are 30 to 50 percent faster end-to-end and cheaper per image at higher volume tiers.

Set thresholds at deployment, not detection

Always request the raw confidence score and apply your business threshold downstream. Different workflows need different thresholds. Label, restrict, and remove are all valid actions.

Persist request_id for support cases

Every response includes a request_id. Logging it makes support investigations 10x faster when you need them.

Cache by image hash for retries

Identical images return identical verdicts. Cache by content hash to deduplicate near-duplicate uploads, which are 5 to 15 percent of real-world traffic.

Use webhooks for async, polling only as fallback

Webhook delivery is faster and cheaper than polling. Reserve polling for cases where webhooks cannot reach you.

Implement client-side rate limiting

Do not rely solely on 429s. SDKs include token-bucket limiters that prevent burst-throttling under load.

Security

We treat every image as sensitive. Encryption everywhere, configurable retention, and SOC 2 Type II certification on Enterprise.

Encryption

TLS 1.2+ in transit. AES-256 at rest. Keys rotated every 90 days.

Data retention

Free and Pro: 30 day log retention, images discarded after detection. Enterprise: configurable, including zero-retention.

Compliance

SOC 2 Type II audited. GDPR-compliant. HIPAA available on Enterprise. EU regional endpoints available.

Access controls

Role-based access in dashboard. SSO and SAML on Enterprise. IP allowlisting on Pro and above.

Audit logs

Every API request and dashboard action is logged. Exportable as CSV or via SIEM webhook on Enterprise.

Penetration testing

Annual third-party pen tests. Reports available under NDA on request.

Need a deeper security review?

SOC 2 reports, pen test summaries, sub-processor lists, and DPA templates are available on request.

Ready to build?

Get an API key in 30 seconds. 500 free scans every month, no credit card.