Try this endpoint →

Service endpoints

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

Method / ProtocolPathContent-Type / FramesAuth
POST/v1/emotion-captioning/pre-recordedmultipart/form-dataAuthorization: <API Key>
GET/v1/tasks/{task_id}—Authorization: <API Key>

Request parameters

Submission returns HTTP 202 with task_id, status=pending and task_type. Poll GET /v1/tasks/{task_id} using an API key from the same account, about once per second. States: pending, running, succeeded, failed, cancelled. Read result on success; read error and stop polling on failure. Maximum audio duration: one hour; upload limit: 20 MiB. Duration is enforced by the executor. Returns 503 when the task service is unavailable; never falls back to a synchronous result.

audio: audio file; mode: sec (default, natural-language captions) or ser (label classification); language: result language hint, such as zh or en.

ParameterTypeRequiredDescription
audiofileYesPCM WAV audio to analyze, up to one hour, maximum 20 MiB.
modestringNosec (default, natural-language caption) or ser (label classification).
languagestringNoLanguage hint, for example zh or en.

Response fields

FieldTypeDescription
task_idstringTask ID from submission; query with GET /v1/tasks/{task_id}.
task_typestringe2v for emotion labels; emotion for captioning.
statusstringpending on submission; pending / running / succeeded / failed / cancelled when queried.
resultobject?Analysis result after successful completion; may be absent before completion.
errorobject?Error details on task failure; stop polling after failure.
usageobject?Usage reported by the server.

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-captioning/pre-recorded' \
  -H "Authorization: $FOURHZ_API_KEY" \
  -F 'audio=@audio.wav' \
  -F 'mode=sec' \
  -F 'language=zh'
curl -X GET 'https://api.fourhz.ai/v1/tasks/TASK_ID' \
  -H "Authorization: $FOURHZ_API_KEY"

Response examples

Submission response: HTTP 202, accepted but not yet analyzed.

{
  "task_id": "task_example",
  "status": "pending",
  "task_type": "emotion"
}

Poll GET /v1/tasks/task_example with credentials from the same account. Example HTTP 200 response after completion:

{
  "task_id": "task_example",
  "task_type": "emotion",
  "status": "succeeded",
  "result": {
    "type": "final_emotion",
    "mode": "sec",
    "label": "Happy",
    "text": "The speaker sounds excited and cheerful.",
    "duration_sec": 2.68,
    "language": "en"
  }
}

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.