PhotoCheck API in Rust
To check a photo for AI generation and faces in Rust, 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. Install
cargo add reqwest --features blocking,multipart,json
cargo add serde_json3. Check a photo
use reqwest::blocking::{multipart, Client};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let key = std::env::var("PHOTOCHECK_API_KEY")?;
let form = multipart::Form::new().file("image", "photo.jpg")?;
let res = Client::new()
.post("https://photocheckapi.com/api/v1/analyze")
.bearer_auth(key)
.multipart(form)
.send()?;
let status = res.status();
let json: serde_json::Value = res.json()?;
if !status.is_success() {
return Err(format!("{}: {}", json["error"]["type"], json["error"]["message"]).into());
}
println!("{}", json["summary"]["text"]);
println!("AI score: {}", json["ai"]["score"]);
Ok(())
}Notes
- Blocking client for brevity; the async client takes the same calls with .await.
- 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, Ruby, Java, C# (.NET).