Audio Deepfake Detection
Check for speech before analyzing synthesis cues. When no speech is detected, the result is “No speech” and no authenticity verdict is made.
Getting started
Authenticate with a 4Hz API key. Send multipart/form-data with required file field audio. The response contains the final result; no asynchronous task is created.
Choose a language for a complete request. Python requires requests (python -m pip install requests). Run JavaScript on a Node.js 22+ server: save it as detect.mjs, then run node detect.mjs. Set the FOURHZ_API_KEY environment variable and place a 1–10 second sample.wav in the current directory. Keep long-lived API keys out of browser code.
curl https://api.fourhz.ai/v1/detect/sync \
-H "Authorization: $FOURHZ_API_KEY" \
-F "audio=@sample.wav" \
-F "model=general" \
-F "threshold=0.9"import os
import requests
api_key = os.environ["FOURHZ_API_KEY"]
with open("sample.wav", "rb") as audio:
response = requests.post(
"https://api.fourhz.ai/v1/detect/sync",
headers={"Authorization": api_key},
files={"audio": ("sample.wav", audio, "audio/wav")},
data={"model": "general", "threshold": "0.9"},
timeout=(10, 120),
)
response.raise_for_status()
result = response.json()
print(result)import { readFile } from "node:fs/promises";
const apiKey = process.env.FOURHZ_API_KEY;
if (!apiKey) throw new Error("Set FOURHZ_API_KEY first");
const audio = await readFile("sample.wav");
const form = new FormData();
form.set("audio", new Blob([audio], { type: "audio/wav" }), "sample.wav");
form.set("model", "general");
form.set("threshold", "0.9");
const response = await fetch("https://api.fourhz.ai/v1/detect/sync", {
method: "POST",
headers: { Authorization: apiKey },
body: form,
signal: AbortSignal.timeout(120_000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
const result = await response.json();
console.log(result);API reference
| Method | Path | Response |
|---|---|---|
| POST | /v1/detect/sync | 200: final detection result |
The service endpoint is https://api.fourhz.ai. Authenticate with a 4Hz API key. Calls are priced per detection. See Pricing for public reference rates; your account quote and billing records determine the actual charge.
| Field | Required | Description |
|---|---|---|
audio | Yes | Audio file · WAV, MP3, M4A, FLAC |
model | Yes | Send one multipart text field with general or telephone. There is no default. If omitted, the API returns HTTP 400: The model field is required. Send general or telephone as a multipart text field. |
threshold | No | Finite number sent as text, strictly between 0 and 1. Default: 0.9 for both models. Higher thresholds reduce false positives but increase missed synthetic audio. Invalid values return HTTP 400 invalid_threshold. |
Maximum file size: 25 MiB; API duration must be 1–15 seconds. The service rejects audio longer than 15 seconds with HTTP 422 without truncating it. Playground recording and upload experiences accept up to 15 seconds. The extension must match the container. The required model text field selects general (General) or telephone (Telephone). See the request parameter table for threshold settings. Select the model in Playground’s Advanced settings. Telephone uses the first 4 seconds and repeats shorter audio; scores are not interchangeable between models. Guest Playground retains its WAV and 20 MB upload restrictions. Requests wait up to 110 seconds without automatic retries.
Response fields
Successful responses return fields at the top level. Values below illustrate the format.
{
"request_id": "example-request-id",
"label": "synthetic",
"synthetic_score": 0.91,
"processing_ms": 1200
}Synthetic scores range from 0 to 1; higher scores indicate synthesis cues, not calibrated forgery probabilities. Labels are synthetic (Likely AI generated speech) or bonafide (Likely human speech). These are model predictions; API labels remain unchanged and parentheses are display explanations. The platform records usage for the authenticated account. The service may also return threshold. Use the returned threshold. Noise, compression, re-recording and short clips affect predictions; results do not guarantee authenticity.
Common statuses: 400/413/422 invalid upload or audio; 401 authentication failed; 403 unavailable key; 415 file content is not supported audio; 429 platform rate limit, concurrency limit or model at capacity (with Retry-After; retry later); 503 service not configured or unavailable; 502/504 connection failure or timeout. Every error body contains error_code and message. A failure is not evidence of authentic audio.
Threshold comparison: general labels scores strictly greater than threshold as synthetic; telephone uses greater than or equal to threshold. See the request parameter table for the range and defaults.