Face Age Detection
Upload an image to find the location of every face in it, along with the approximate age of each face. Each detection costs credits; for charging rules, see Credits and Billing.
Upload the image directly as a file (multipart/form-data); there is no need to convert it to base64.
POST /api/v2/tasks/detect-face
X-Api-Key: sk-live-xxxx
Content-Type: multipart/form-data
Idempotency-Key: optional, see Image to Video
Full example
curl -X POST https://yuyuvideo.com/api/v2/tasks/detect-face \
-H "X-Api-Key: sk-live-xxxx" \
-F "image=@photo.jpg" \
-F "callback_url=https://example.com/webhooks/yuyu-detect-face"
On success, the API returns 202 Accepted with the task data (type is 3), meaning the system has received the image and is running detection. credits is the number of credits charged for this request; the number in the example is for reference only. If you resend with the same Idempotency-Key, the API returns 200 OK with the original task.
{
"public_id": "01K1M2N3P4Q5R6S7T8V9W0XY14",
"type": 3,
"status": 10,
"credits": 5,
"params": {
"model": "YUYU_M5",
"images": ["uploads/01K1M2N3P4Q5R6S7T8V9W0XY15.jpg"]
},
"result": null,
"error_code": null,
"error_message": null,
"created_at": "2026-10-19T08:00:00.000000Z",
"finished_at": null,
"files_expire_at": null,
"files_expired": false,
"files": []
}
status is usually 10 (processing) and occasionally 0 (queued). In either case, just wait for the webhook notification or query the task. The result of this type of task is not a file, so files is always an empty array, and files_expire_at and files_expired are not used.
Detection usually completes within a few seconds. Once it completes (status = 20), the result in the webhook notification and in GET /api/tasks/{public_id} looks like this:
{
"result": {
"face_coordinates": [
{ "index": 0, "bbox": [41, 49, 131, 146], "age": 4 },
{ "index": 1, "bbox": [328, 274, 415, 388], "age": 2 }
]
}
}
If there are no faces in the image, face_coordinates is an empty array []. This is a normal completion, not a failure. If detection fails, the task becomes 30 (failed) and the credits charged for it are fully refunded.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
image |
file | Yes | Image file. PNG, JPG, JPEG, and WebP are supported, up to 10 MB |
model |
string | No | Defaults to YUYU_M5 if omitted |
callback_url |
string | No | URL to notify when the task finishes. Must start with https://, up to 2000 characters. Notifications for this type of task also include result; see below |
You can detect only one image per request. To detect multiple images, call the API once per image. Each call is charged separately and gets its own public_id.
Parameters not listed in the table return 422 if sent. They are not ignored.
result.face_coordinates fields
| Field | Description |
|---|---|
index |
Face number, starting from 0 |
bbox |
Face location [x1, y1, x2, y2], i.e. the coordinates of the top-left and bottom-right corners. In pixels, relative to the original image |
age |
Age bracket (integer); see the table below |
age reference
age |
Age |
|---|---|
0 |
0–2 years |
1 |
3–9 years |
2 |
10–19 years |
3 |
20–29 years |
4 |
30–39 years |
5 |
40–49 years |
6 |
50–59 years |
7 |
60–69 years |
8 or higher |
70 years and older |
Webhook notification differences
Webhook notifications for face age detection include an extra result field compared with other tasks. It contains the detection result directly, so you don't need to query the task again:
{
"public_id": "01K1M2N3P4Q5R6S7T8V9W0XY14",
"status": 20,
"error_code": null,
"payload": null,
"result": {
"face_coordinates": [
{ "index": 0, "bbox": [41, 49, 131, 146], "age": 4 }
]
}
}
When the task fails (status = 30), result is still present, but its value is null. Notifications for other tasks (such as image to video) do not include result; for their format, see Callbacks (Webhook).
Errors
| Status code | Cause | Response |
|---|---|---|
422 |
Invalid parameters, such as no image uploaded, an unsupported file format, a file over 10 MB, or a malformed callback_url |
The errors field lists the error for each field |
422 |
model is set to a model that does not exist |
{ "message": "Unknown model alias: {model}" } |
402 |
Insufficient credits | { "message": "Insufficient credits to complete this charge." } |
429 |
Too many requests, or too many queued detection tasks | The response includes a Retry-After header; wait before sending again |
To check progress, see Query Tasks and Download Results. For charging rules, see Credits and Billing.
Legacy API
If you have already integrated the legacy POST /api/tasks/detect-face (sent as JSON, with one base64 data URI in images, model required, and 201 Created returned on success), you can keep using it without changes. Detection results, webhook notifications, and billing are the same as the new version.
For new integrations, use POST /api/v2/tasks/detect-face described on this page.