PhotoCheck API

PhotoCheck API in PHP

To check a photo for AI generation and faces in PHP, POST it to https://photocheckapi.com/api/v1/analyze with your key as a Bearer token. The response is JSON with ai.score, faces.count and the file's metadata. The example below is complete and runs as it is.

1. Set your key

shell
export PHOTOCHECK_API_KEY="pc_live_…"

No key yet? Leave the header out: you get 5 keyless calls a day to try it. Credit packs start at $4.95.

2. Check a photo

PHP
<?php
$ch = curl_init("https://photocheckapi.com/api/v1/analyze");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("PHOTOCHECK_API_KEY")],
    CURLOPT_POSTFIELDS => ["image" => new CURLFile("photo.jpg")],
    CURLOPT_TIMEOUT => 30,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$result = json_decode($body, true);
if ($status !== 200) {
    throw new RuntimeException($result["error"]["message"] ?? "HTTP $status");
}
echo $result["summary"]["text"], PHP_EOL;
echo "AI score: ", $result["ai"]["score"], PHP_EOL;

Notes

  • Uses the curl extension that ships with almost every PHP build.
  • In Laravel: Http::withToken(env('PHOTOCHECK_API_KEY'))->attach('image', file_get_contents($path), 'photo.jpg')->post($url).
  • Swap /analyze for /faces, /ai-detect or /metadata to run one check. Each costs the same one credit.
  • Branch on error.type rather than the HTTP status alone; the full list is in the error reference.

Other languages

cURL, JavaScript (Node.js), Python, Go, Ruby, Java, C# (.NET), Rust.