Try this endpoint →

Service endpoints

Service URL: https://api.fourhz.ai

Method / ProtocolPathContent-Type / FramesAuth
POST/v1/emotion-recognition/syncmultipart/form-dataAuthorization: <API Key>

Request parameters

Returns the final result with HTTP 200, never a pending task_id. PCM WAV only, 80 ms–15 seconds, maximum 20 MiB. Server processing waits up to 120 seconds. A normal synchronous call returns its final result without polling. A timeout or disconnect does not prove cancellation; do not retry blindly. Keep any job_id or X-Job-Id for investigation, and query a task only when its ID is available.

file: audio file. Returns best_label, best_score, top_emotions and duration_seconds when reported.

ParameterTypeRequiredDescription
filefileYesPCM WAV audio to analyze, 80 ms–15 seconds, maximum 20 MiB.

Response fields

FieldTypeDescription
filenamestringUploaded filename.
duration_secondsnumberProcessed audio duration in seconds.
best_labelstringBest emotion label.
best_scorenumber?Model score when returned; not a calibrated probability.
top_emotions[]array?Candidate emotions and scores when returned.

Request examples

Python uses requests. JavaScript file examples use Node.js 22+. Long-lived keys are server-side only.

curl -X POST 'https://api.fourhz.ai/v1/emotion-recognition/sync' \
  -H "Authorization: $FOURHZ_API_KEY" \
  -F 'file=@audio.wav'

Response examples

HTTP 200 returns the final result directly; no polling. Scores and text illustrate the response structure.

{
  "filename": "audio.wav",
  "best_label": "happy",
  "best_score": 0.91,
  "top_emotions": [
    {
      "label": "happy",
      "score": 0.91
    },
    {
      "label": "neutral",
      "score": 0.07
    }
  ],
  "duration_seconds": 2.68
}

Errors

Every HTTP error body contains error_code (machine-readable) and message (human-readable). Legacy fields such as detail, code/msg or an upstream error object are kept and status codes are unchanged. Clients should read error_code and message first.

Common statuses: 400 invalid parameters or audio; 401 authentication failed; 402 insufficient balance; 413 file too large; 415 file content is not supported audio; 429 rate limit or capacity full (honor Retry-After); 503 service not configured or unavailable.