AgentSkillsCN

didit-face-match

集成Didit Face Match独立API,用于比对两张人脸图像。当用户希望通过Didit实现人脸比对、人脸身份验证、生物特征比对、人脸识别,或进行自拍与证件的匹配时,可选用此API。该API会返回一个相似度评分(0–100),并支持自定义阈值以控制判定标准。同时,它还支持图像旋转及多人脸检测功能。

SKILL.md
--- frontmatter
name: didit-face-match
description: >
  Integrate Didit Face Match standalone API to compare two facial images.
  Use when the user wants to compare faces, verify face identity, implement biometric
  comparison, facial recognition, or selfie-to-document matching using Didit.
  Returns a similarity score (0-100) with configurable decline threshold.
  Supports image rotation and multi-face detection.
version: 1.2.0
metadata:
  openclaw:
    requires:
      env:
        - DIDIT_API_KEY
    primaryEnv: DIDIT_API_KEY
    emoji: "👥"
    homepage: https://docs.didit.me

Didit Face Match API

Overview

Compares two facial images to determine if they belong to the same person. Returns a similarity score (0-100).

Key constraints:

  • Supported formats: JPEG, PNG, WebP, TIFF
  • Maximum file size: 5MB per image
  • If multiple faces in an image, the largest face is used for comparison
  • Both user_image and ref_image are required

Capabilities: Similarity scoring, age estimation, gender detection, face bounding boxes, configurable decline threshold, optional image rotation for non-upright faces.

API Reference: https://docs.didit.me/reference/face-match-standalone-api


Authentication

All requests require x-api-key header. Get your key from Didit Business Console → API & Webhooks.


Endpoint

code
POST https://verification.didit.me/v3/face-match/

Headers

HeaderValueRequired
x-api-keyYour API keyYes
Content-Typemultipart/form-dataYes

Request Parameters (multipart/form-data)

ParameterTypeRequiredDefaultConstraintsDescription
user_imagefileYesJPEG/PNG/WebP/TIFF, max 5MBUser's face image to verify
ref_imagefileYesSame as aboveReference image to compare against
face_match_score_decline_thresholdintegerNo300-100Scores below this = Declined
rotate_imagebooleanNofalseTry 0/90/180/270 degree rotations to find upright face
save_api_requestbooleanNotrueSave in Business Console Manual Checks
vendor_datastringNoYour identifier for session tracking

Example

python
import requests

response = requests.post(
    "https://verification.didit.me/v3/face-match/",
    headers={"x-api-key": "YOUR_API_KEY"},
    files={
        "user_image": ("selfie.jpg", open("selfie.jpg", "rb"), "image/jpeg"),
        "ref_image": ("id_photo.jpg", open("id_photo.jpg", "rb"), "image/jpeg"),
    },
    data={"face_match_score_decline_threshold": "50"},
)
typescript
const formData = new FormData();
formData.append("user_image", selfieFile);
formData.append("ref_image", referenceFile);
formData.append("face_match_score_decline_threshold", "50");

const response = await fetch("https://verification.didit.me/v3/face-match/", {
  method: "POST",
  headers: { "x-api-key": "YOUR_API_KEY" },
  body: formData,
});

Response (200 OK)

json
{
  "request_id": "a1b2c3d4-...",
  "face_match": {
    "status": "Approved",
    "score": 80,
    "user_image": {
      "entities": [
        {"age": 27.63, "bbox": [40, 40, 100, 100], "confidence": 0.717, "gender": "male"}
      ],
      "best_angle": 0
    },
    "ref_image": {
      "entities": [
        {"age": 22.16, "bbox": [156, 234, 679, 898], "confidence": 0.717, "gender": "male"}
      ],
      "best_angle": 0
    },
    "warnings": []
  },
  "created_at": "2025-05-01T13:11:07.977806Z"
}

Status Values & Handling

StatusMeaningAction
"Approved"Score >= thresholdFaces match — proceed
"Declined"Score < threshold or no faceCheck warnings for details. May need better image
"In Review"Needs manual reviewWait for review or retrieve via session API

Error Responses

CodeMeaningAction
400Invalid requestCheck file format, size, parameters
401Invalid API keyVerify x-api-key header
403Insufficient creditsTop up at business.didit.me

Response Field Reference

FieldTypeDescription
statusstring"Approved", "Declined", "In Review"
scoreinteger0-100 similarity score (higher = more similar). null if no face found
entities[].agefloatEstimated age
entities[].bboxarrayFace bounding box [x1, y1, x2, y2]
entities[].confidencefloatFace detection confidence (0-1)
entities[].genderstring"male" or "female"
best_angleintegerBest rotation angle for the face
warningsarray{risk, log_type, short_description, long_description}

Warning Tags

TagDescriptionAuto-Decline
NO_REFERENCE_IMAGEReference or face image missingYes
NO_FACE_DETECTEDNo face detected in one or both imagesYes
LOW_FACE_MATCH_SIMILARITYScore below threshold — potential identity mismatchConfigurable

Security best practice: Only store the status and score. Minimize biometric image data on your servers. Image URLs (in workflow mode) expire after 60 minutes.


Score Interpretation

Score RangeInterpretationAction
90-100Very high confidence — same personAuto-approve
70-89High confidence — likely same personApprove (default threshold 30)
50-69Moderate — possible matchConsider manual review
30-49Low — likely different peopleDeclined at default threshold
0-29Very low — different peopleDeclined

Utility Scripts

bash
export DIDIT_API_KEY="your_api_key"

python scripts/match_faces.py selfie.jpg id_photo.jpg
python scripts/match_faces.py selfie.jpg id_photo.jpg --threshold 50 --rotate