face-api.js made face recognition in JavaScript easy, but its last release (0.22.2) shipped in March 2020 and still pins TensorFlow.js core 1.7.0. The best-known fork, @vladmandic/face-api, is now archived too, yet the two packages still pull about 465,000 and 518,000 npm downloads a month.
Here is how to replace it with a face recognition API from Node.js 20: built-in fetch and FormData , no SDK, no model weights, no canvas or tfjs-node build. All code below ran against the live API.
Want to run it on your own photos? Get a key for the Face Analyzer API .
face-api.js calls mapped to endpoints
face-api.js Face Analyzer API
nets.*.loadFromDisk("./models") nothing to load
detectAllFaces().withFaceLandmarks() /faceanalysis ( boundingBox , landmarks )
.withAgeAndGender() , .withFaceExpressions() /faceanalysis ( AgeRange , Gender , Emotions )
euclideanDistance(d1, d2) < 0.6 /compare-faces ( matchedFaces , unmatchedFaces )
new FaceMatcher(labeledDescriptors) /save-face-in-repository with…