PhotoCheck API in Ruby
To check a photo for AI generation and faces in Ruby, 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
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
require "net/http"
require "json"
uri = URI("https://photocheckapi.com/api/v1/analyze")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV.fetch("PHOTOCHECK_API_KEY")}"
req.set_form([["image", File.open("photo.jpg")]], "multipart/form-data")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
result = JSON.parse(res.body)
raise "#{result.dig("error", "type")}: #{result.dig("error", "message")}" unless res.is_a?(Net::HTTPSuccess)
puts result["summary"]["text"]
puts "AI score: #{result["ai"]["score"]}, faces: #{result["faces"]["count"]}"Notes
- Standard library only (net/http).
- In Rails, call it from a job rather than the request cycle if you check many images at once.
- Swap
/analyzefor/faces,/ai-detector/metadatato run one check. Each costs the same one credit. - Branch on
error.typerather than the HTTP status alone; the full list is in the error reference.
Other languages
cURL, JavaScript (Node.js), Python, PHP, Go, Java, C# (.NET), Rust.