Detect Faces in Images
April 24, 2025
Table of contents
This endpoint detects faces in the provided image and returns face information, including positions and features. This is useful for identifying facial features prior to using them with POST /images/kolors with the face
reference type.
You can execute an unlimited number of face detections for free. This feature is available for all Kling subscription plans, including the free one.
https://api.useapi.net/v1/kling/images/recognize-faces
Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Alternatively you can use multipart/form-data
# Content-Type: multipart/form-data
API token
is required, see Setup useapi.net for details.
Request Body
{
"email": "[email protected]",
"imageReference": "https://example.com/image.jpg"
}
-
email
is optional when only one account configured.
However, if you have multiple accounts configured, this parameter becomes required. -
imageReference
is required, the URL of the image to analyze.
You can upload images using POST /assets and use the returned URL here.
Responses
-
{ "status": 0, "message": "", "faceItems": [ { "name": "face_0", "resources": [ { "name": "face", "type": "image", "url": "https://s21-kling.klingai.com/...face_0.jpg", "marginTop": 0, "countInRow": 1 }, { "name": "face_feature", "type": "image", "url": "https://s21-kling.klingai.com/...face_feature_0.jpg", "marginTop": 0, "countInRow": 1 } ], "arguments": [ { "name": "face_bound", "value": "{\"x\":120,\"y\":80,\"width\":200,\"height\":240}" } ] } ], "mediaInfo": { "type": "image", "duration": 0, "width": 724, "height": 1268 } }
-
{ "error": "Parameter imageReference is required" }
-
{ "error": "Unauthorized", "code": 401 }
If the response contains faceItems
, it means faces were detected in the image. Each face is listed with its position and features. The response will include:
status
: 0 indicates successfaceItems
: An array of detected faces, each with:resources
: Face images and feature informationarguments
: Contains face bounding box coordinates
mediaInfo
: Information about the original image
Model
{ // TypeScript, all fields are optional
status: number // 0 for success
message: string // Empty string on success, error message otherwise
faceItems?: {
name: string // Face identifier (e.g., "face_0")
resources: {
name: string // Resource type identifier (e.g., "face", "face_feature")
type: string // Resource type (typically "image")
url: string // URL to the resource
marginTop: number // Display margin
countInRow: number // Display count in row
}[]
arguments: {
name: string // Argument name (e.g., "face_bound")
value: string // JSON string with facial bounds coordinates
}[]
}[]
mediaInfo: {
type: string // Media type (typically "image")
duration: number // Duration for video (0 for image)
width: number // Image width in pixels
height: number // Image height in pixels
}
}
Examples
-
curl -X POST "https://api.useapi.net/v1/kling/images/recognize-faces" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer …" \ -d '{ "email": "[email protected]", "imageReference": "https://example.com/image.jpg" }'
-
const token = "API token"; const email = "Previously configured account email"; const apiUrl = "https://api.useapi.net/v1/kling/images/recognize-faces"; const response = await fetch(apiUrl, { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: JSON.stringify({ email: email, imageReference: "https://example.com/image.jpg" }) }); const result = await response.json(); console.log("response", {response, result});
-
import requests token = "API token" email = "Previously configured account email" apiUrl = "https://api.useapi.net/v1/kling/images/recognize-faces" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } data = { "email": email, "imageReference": "https://example.com/image.jpg" } response = requests.post(apiUrl, headers=headers, json=data) print(response, response.json())