Tencent Cloud FaceID SDK for Python

raw JSON →
3.1.80 verified Sat May 09 auth: no python

Official Tencent Cloud SDK for FaceID, providing facial recognition and liveness detection APIs. Current version 3.1.80. Releases follow Tencent Cloud SDK cadence, typically bi-weekly.

pip install tencentcloud-sdk-python-faceid
error ModuleNotFoundError: No module named 'tencentcloud.faceid'
cause Missing pip install tencentcloud-sdk-python-faceid, or missing common dependency.
fix
pip install tencentcloud-sdk-python-common tencentcloud-sdk-python-faceid
error AttributeError: module 'tencentcloud.faceid' has no attribute 'v20180301'
cause Old style import without version subpackage; SDK v3 requires version in path.
fix
Use from tencentcloud.faceid.v20180301 import faceid_client
breaking The SDK v3 major restructuring moved versioned subpackages; imports without v20180301 will fail.
fix Use from tencentcloud.faceid.v20180301 import faceid_client, models
deprecated Old method `FaceidClient.__init__` without endpoint parameter is deprecated. Use `client = FaceidClient(cred, region, endpoint)` or default endpoint.
fix Pass region as second argument; endpoint is optional.
gotcha Region parameter is required but many users omit it, causing client initialization failure.
fix Always specify a region string (e.g., 'ap-guangzhou').

Initialize client and call DetectAuth (face verification). Requires credentials and RuleId from Tencent Cloud console.

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.faceid.v20180301 import faceid_client, models

secret_id = os.environ.get('TENCENTCLOUD_SECRET_ID', '')
secret_key = os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
cred = credential.Credential(secret_id, secret_key)
client = faceid_client.FaceidClient(cred, "ap-guangzhou")
req = models.DetectAuthRequest()
req.RuleId = "your_rule_id"
try:
    resp = client.DetectAuth(req)
    print(resp.to_json_string())
except TencentCloudSDKException as e:
    print(e)