tencent cloud

APIs

DetectFaceSimilarity

Download
Focus Mode
Font Size
Last updated: 2026-08-11 16:45:21

1. API Description

Domain name for API request: iai.intl.tencentcloudapi.com.

This API is used to perform similarity comparison between human faces in two images and return the facial similarity score.

If you need to judge whether a person is a specific individual, that is, to verify whether a person in an image is a known identity, for example in common log in scenarios such as face verification, we recommend using the face verification (https://www.tencentcloud.com/document/product/867/44983?from_cn_redirect=1) or person verification (https://www.tencentcloud.com/document/product/867/44982?from_cn_redirect=1) api.

  • Please use the V3 version for the signature method in the public parameters. In other words, set the SignatureMethod parameter to TC3-HMAC-SHA256.
We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: DetectFaceSimilarity.
Version Yes String Common Params. The value used for this API: 2020-03-03.
Region No String Common Params. This parameter is not required.
ImageA No String

A base64-encoded image.

  • The size after base64 encoding must not exceed 5 MB.
  • For jpg format, the long side pixel must not exceed 4000. For other formats, the long side pixel must not exceed 2000. The short side pixel for all formats must be greater than or equal to 64.
  • If the image contains several faces, only the face with the highest confidence degree is selected.
  • Supports PNG, jpg, JPEG, and BMP formats. GIF images are not supported.
ImageB No String

base64 data of image B.

  • The size after base64 encoding must not exceed 5M.
  • For jpg format, the long side pixel cannot exceed 4000. For other formats, the long side pixel cannot exceed 2000. The short side pixel of images in all formats must not be less than 64.
  • If the image contains several faces, only the face with the highest confidence degree is selected.
  • Supports PNG, jpg, JPEG, and BMP. GIF images are not supported.
UrlA No String

Url of Image A.

  • Size of the corresponding Image after base64 encoding must not exceed 5 MB.
  • For jpg format, the long side pixel must not exceed 4000. For other formats, the long side pixel cannot exceed 2000. The short side pixel for all formats must be not less than 64.
  • Either the Url or the Image of picture A must be provided. If both are provided, only the Url is used.
  • URLs of images stored in Tencent Cloud guarantee higher download speed and stability. It is recommended to store images in Tencent Cloud.
  • Speed and stability of URLs not stored in Tencent Cloud may be impacted.
  • If the Image contains several faces, only the human face with the maximum area is selected.
  • Supports PNG, jpg, jpg, JPEG, BMP. GIF images are not supported.
UrlB No String

Url of Image B.

  • The size of the corresponding Image after base64 encoding must not exceed 5 MB.
  • For jpg format, the long side pixel cannot exceed 4000. For other formats, the long side pixel cannot exceed 2000. For all formats, the short side pixel must be not less than 64.
  • Either the Url or the Image of picture B must be provided. If both are provided, only the Url is used.
  • URLs of images stored in Tencent Cloud guarantee higher download speed and stability. It is recommended to store images in Tencent Cloud.
  • The speed and stability of URLs not stored in Tencent Cloud may be affected to a certain degree.
  • If the Image contains several faces, only the face with the maximum area is selected.
  • PNG, jpg, JPEG, and BMP are supported. GIF images are not supported.
QualityControl No Integer

Image quality control.

  • Value ranges from 0 to 4:
    0: No control;
    1: Low quality requirement. The image has at least one of the following: super blurry, eye occlusion, nose occlusion, or mouth occlusion;
    2: Normal quality requirement. The image has at least three of the following: too bright, dark, blurry, normal blur, eyebrow obstruction, cheek obstruction, or chin obstruction;
    3: Relatively high quality requirement. The image has one or two of the following: too bright, dark, normal blur, eyebrow obstruction, cheek obstruction, or chin obstruction;
    4: High quality requirement. All dimensions are the best or most, with a minor problem in one dimension;
    Default is 0.

  • If the image quality fails to satisfy the requirement, the returned result will prompt that the image quality detection does not meet the requirement.

3. Output Parameters

Parameter Name Type Description
Score Float

Value ranges from 0.00 to 100.00.
It is recommended to judge as the same person when the similarity is equal to or greater than 70 (a fixed threshold of 70 is used, with a false acceptance rate of 1 in 10,000, and the threshold cannot be adjusted).

RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Face Similarity Detection API Exception Example

Input Example

POST / HTTP/1.1
Host: iai.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DetectFaceSimilarity
<Common request parameters>

{
    "UrlA": "http://test.image.myqcloud.com/testA.jpg",
    "UrlB": "http://test.image.myqcloud.com/testB.jpg"
}

Output Example

{
    "Response": {
        "Error": {
            "Code": "FailedOperation.FaceQualityNotQualified",
            "Message": "Face image quality does not meet the requirement."
        },
        "RequestId": "788270e8-91b7-4c59-bd00-1af257b1e482"
    }
}

Example2 Face Similarity Detection API Successful Example

Input Example

POST / HTTP/1.1
Host: iai.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DetectFaceSimilarity
<Common request parameters>

{
    "UrlA": "http://test.image.myqcloud.com/testA.jpg",
    "UrlB": "http://test.image.myqcloud.com/testB.jpg"
}

Output Example

{
    "Response": {
        "Score": 0.999,
        "RequestId": "a8eb4545-a154-4f86-9510-57a8be9cae0c"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
AuthFailure.InvalidAuthorization Authentication failed.
FailedOperation.CompareFail Comparison failed.
FailedOperation.ConflictOperation The operations conflict. Do not operate on the same person simultaneously.
FailedOperation.DuplicatedGroupDescription The custom description field must be unique in the group.
FailedOperation.FaceQualityNotQualified The face image quality does not meet the requirement.
FailedOperation.FaceSizeTooSmall The face frame size is smaller than the MinFaceSize value, and the face is filtered out.
FailedOperation.GroupInDeletedState The current group is being deleted. Please wait.
FailedOperation.GroupPersonMapExist The ID of the corresponding person is already in the group.
FailedOperation.GroupPersonMapNotExist The ID of the corresponding person is not in the group.
FailedOperation.ImageDecodeFailed Image decoding failed.
FailedOperation.ImageDownloadError An error occurred while downloading the image.
FailedOperation.ImageFacedetectFailed Face detection failed.
FailedOperation.ImageResolutionExceed The image resolution is too high.
FailedOperation.ImageResolutionTooSmall The image short edge resolution is smaller than 64.
FailedOperation.ImageSizeExceed The size of the Base64-encoded image cannot exceed 5 MB.
FailedOperation.LifePhotoDetectFaces Multiple faces detected.
FailedOperation.LifePhotoDetectFake Real person comparison failed.
FailedOperation.LifePhotoDetectNoFaces Full face not detected.
FailedOperation.LifePhotoSizeError Uploaded image too large or too small.
FailedOperation.RequestTimeout The backend service timed out.
FailedOperation.RpcFail The RPC call failed.
FailedOperation.SearchFacesExceed The number of faces searched for exceeds the limit.
FailedOperation.ServerError The algorithm service is exceptional. Please retry.
FailedOperation.UnKnowError An internal error occurred.
InternalError Internal error.
InvalidParameter.InvalidParameter Invalid parameter.
InvalidParameterValue.AccountFaceNumExceed The number of faces in the account exceeds the limit.
InvalidParameterValue.DeleteFaceNumExceed The number of faces to be deleted exceeds the limit. Every person must have at least one face image.
InvalidParameterValue.FaceModelVersionIllegal The algorithm model version is invalid.
InvalidParameterValue.GroupExDescriptionsExceed The array length of the group's custom description fields exceeds the limit. Up to 5 fields can be created.
InvalidParameterValue.GroupExDescriptionsNameIdentical The name of the group's custom description field must be unique.
InvalidParameterValue.GroupExDescriptionsNameIllegal The name of the group's custom description field contains invalid characters. It can contain only letters, -, _, and digits.
InvalidParameterValue.GroupExDescriptionsNameTooLong The name of the group's custom description field exceeds the length limit.
InvalidParameterValue.GroupFaceNumExceed The number of faces in the group exceeds the limit.
InvalidParameterValue.GroupIdAlreadyExist The group ID already exists. It must be unique.
InvalidParameterValue.GroupIdIllegal The group ID contains invalid characters. It can contain only letters, digits, and special symbols (-%@#&_).
InvalidParameterValue.GroupIdNotExist The group ID does not exist.
InvalidParameterValue.GroupIdTooLong The group ID exceeds the length limit.
InvalidParameterValue.GroupIdsExceed The list of groups passed in exceeds the limit.
InvalidParameterValue.GroupNameAlreadyExist The group name already exists. It must be unique.
InvalidParameterValue.GroupNameIllegal The group name contains invalid characters. It can contain only letters, -, _, and digits.
InvalidParameterValue.GroupNameTooLong The group name exceeds the length limit.
InvalidParameterValue.GroupNumExceed The number of groups exceeds the limit. If you need more, please contact us.
InvalidParameterValue.GroupNumPerPersonExceed The number of groups exceeds the limit. One person can be added to up to 100 groups.
InvalidParameterValue.GroupTagIllegal The group remarks field contains invalid characters. It can contain only letters, -, _, and digits.
InvalidParameterValue.GroupTagTooLong The group remarks field exceeds the length limit.
InvalidParameterValue.ImageEmpty Empty image.
InvalidParameterValue.LimitExceed The number of returned results exceeds the limit.
InvalidParameterValue.NoFaceInGroups There are no faces in the specified group.
InvalidParameterValue.NoFaceInPhoto There are no faces in the image.
InvalidParameterValue.OffsetExceed The starting number is too large. Please check the length of the array to be requested.
InvalidParameterValue.PersonExDescriptionInfosExceed The array length of the person's custom description fields exceeds the limit. Up to 5 fields are allowed.
InvalidParameterValue.PersonExDescriptionsNameIdentical The name of the person's custom description field must be unique.
InvalidParameterValue.PersonExDescriptionsNameIllegal The name of the person's custom description field contains invalid characters. It can contain only letters, -, _, and digits.
InvalidParameterValue.PersonExDescriptionsNameTooLong The name of the person's custom description field exceeds the length limit.
InvalidParameterValue.PersonExistInGroup The ID of the corresponding person is already in the group.
InvalidParameterValue.PersonFaceNumExceed The number of face images for the person exceeds the limit. One person can have up to 5 face images.
InvalidParameterValue.PersonGenderIllegal An error occurred while setting person gender. 0: empty; 1: male; 2: female.
InvalidParameterValue.PersonIdAlreadyExist The person ID already exists. It must be unique.
InvalidParameterValue.PersonIdIllegal The person ID contains invalid characters. It can contain only letters, digits, and -%@#&_.
InvalidParameterValue.PersonIdNotExist The person ID does not exist.
InvalidParameterValue.PersonIdTooLong The person ID field exceeds the length limit.
InvalidParameterValue.PersonNameIllegal The person name contains invalid characters. It can contain only letters, -, _, and digits.
InvalidParameterValue.PersonNameTooLong The person name exceeds the length limit.
InvalidParameterValue.QualityControlIllegal Invalid QualityControl parameter.
InvalidParameterValue.SearchPersonsExceed The number of persons searched for exceeds the limit.
InvalidParameterValue.UploadFaceNumExceed Up to four faces can be uploaded at a time.
InvalidParameterValue.UrlIllegal Invalid URL format.
LimitExceeded.ErrorFaceNumExceed The number of faces exceeds the limit.
MissingParameter.ErrorParameterEmpty A required parameter is empty.
ResourceUnavailable.Delivering The resource is being shipped.
ResourceUnavailable.Freeze The account has been frozen.
ResourceUnavailable.InArrears The account is in arrears.
ResourceUnavailable.LowBalance Insufficient balance.
ResourceUnavailable.NotExist The billing status is unknown. Please check whether the service has been activated in the console.
ResourceUnavailable.Recover The resource has been repossessed.
ResourceUnavailable.StopUsing Services for the account has been stopped.
ResourceUnavailable.UnknownStatus The billing status is unknown.
ResourcesSoldOut.ChargeStatusException The billing status is exceptional.
UnsupportedOperation.UnknowMethod Unknown method name.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback