Everything you need to ship face recognition.
A REST API with multipart uploads in and JSON out. Enroll people, identify a face, compare two photos. Most teams send their first verify in minutes.
Overview
The API is REST-based. Image uploads go in as multipart form bodies, responses come back as JSON, and results use standard HTTP status codes. HTTPS is required in production.
Every response also carries a stable status string. Branch on that, not on the HTTP code alone.
curl -X POST https://tareef.g4t.io/api/v1/verify \ -H "Authorization: Bearer frs_live_XXXXXX" \ -F "file=@photo.jpg"
Quickstart
Laravel SDK
tareef/laravel wraps every endpoint in a facade, with typed exceptions and streamed uploads. It needs PHP 8.2+ and Laravel 10, 11, 12 or 13.
Optional config
TAREEF_BASE_URLdefaults to the hosted APITAREEF_TIMEOUTandTAREEF_RETRIESTAREEF_THROW_ON_QUOTAset to false to suppress the quota exception
Image inputs
Pass an UploadedFile, an SplFileInfo or an absolute path. Uploads are streamed, never buffered in memory.
Exceptions
| Exception | Thrown when |
|---|---|
FaceAlreadyExistsException | The face is already enrolled on this account |
NoFaceDetectedException | No detectable face in the image |
QuotaExceededException | The monthly verify quota is reached |
AuthenticationException | The key is bad or revoked |
ServiceUnavailableException | The service is down or unreachable |
All of them extend TareefException.
composer require tareef/laravel
# then in .env
TAREEF_API_KEY=frs_live_XXXXXX
use Tareef\Laravel\Facades\Tareef; use Tareef\Laravel\Exceptions\{NoFaceDetectedException, QuotaExceededException}; // Enroll someone from an uploaded file $person = Tareef::register( name: 'Jane Doe', images: [$request->file('photo')], phone: '+15555555555', ); // Identify a face try { $result = Tareef::verify($request->file('selfie')); if ($result->matched) { return ['uuid' => $result->person->uuid, 'score' => $result->score]; } } catch (NoFaceDetectedException) { abort(422, 'No face in the photo.'); } catch (QuotaExceededException) { abort(429, 'Monthly verify quota hit.'); }
Node.js SDK
@g4t/tareef is a zero-dependency typed wrapper for Node 18+. It ships ESM and TypeScript types.
Configuration
baseUrl defaults to the hosted instance. Override it with the option or with TAREEF_BASE_URL.
Image inputs
Pass a file path, a Buffer or Uint8Array, a Blob or File, or { data, filename }. Uploads are sent as multipart.
Errors
FaceAlreadyExistsErrorcarries the existing.uuidNoFaceDetectedErrorQuotaExceededErrorAuthenticationErrorServiceUnavailableError
All of them subclass TareefError.
npm install @g4t/tareef
# then set your key in the environment
export TAREEF_API_KEY=frs_live_XXXXXX
import { TareefClient, NoFaceDetectedError } from '@g4t/tareef'; const tareef = new TareefClient({ apiKey: 'frs_live_XXXXXX' }); // Enroll a person from local files const person = await tareef.register({ name: 'Jane Doe', images: ['./jane.jpg'], }); // Identify a face try { const r = await tareef.verify('./selfie.jpg'); if (r.success) console.log(r.name, r.score); } catch (e) { if (e instanceof NoFaceDetectedError) console.log('No face in the photo.'); }
Authentication
Send an Authorization: Bearer <key> header on every authenticated request. Legacy clients can use an x-api-key header instead.
- Keys come from your dashboard and are bound to one account.
- A key is
frs_live_followed by at least 32 random characters. - Revoking a key disables it immediately.
- Missing or invalid credentials return
401 unauthorizedwith no further detail.
Authorization: Bearer frs_live_XXXXXX
Enroll a person
Creates a person in your library from one or more reference photos.
Body parameters
| Name | Type | Description |
|---|---|---|
namerequired | string | Display name. |
phoneoptional | string | Free-form identifier: a phone, an email or an employee ID. |
filefile or files[] | file | A single image (jpg, png, webp), 8 MB at most. |
files[]file or files[] | file[] | Several images. Repeat the key once per file. More samples improve later accuracy. |
curl -X POST https://tareef.g4t.io/api/v1/people \ -H "Authorization: Bearer frs_live_XXXXXX" \ -F "name=Jane Doe" \ -F "phone=+15555555555" \ -F "file=@photo.jpg"
Responses
200Returnssuccess: truewith the newuuidandimages_registered.422 face_existsThe face is already enrolled. The existing UUID comes back.422 no_faceNo detectable face in any image you sent.422 spoof_detectedWith liveness on, every photo looks like a screen or a print, so nothing is enrolled. If only some fail, the rest are enrolled andimages_rejected_spoofcounts the discarded ones.
Add reference photos
Attaches more photos to a person you already enrolled. The body is the same as enrollment without name and phone. Each extra sample improves accuracy.
Path parameters
| Name | Description |
|---|---|
uuidrequired | The person UUID returned by enrollment. |
curl -X POST https://tareef.g4t.io/api/v1/people/UUID/images \ -H "Authorization: Bearer frs_live_XXXXXX" \ -F "files=@a.jpg" -F "files=@b.jpg"
Identify a face
billableSearches every photo of every person in your library and returns the best match. Pass person_uuid to score the photo against one person only. Each call counts against your monthly quota.
Body parameters
| Name | Type | Description |
|---|---|---|
filerequired | file | The query image. One embedding is extracted and the best match returned. |
person_uuidoptional | string | Checks one known person ("is this them?") in place of a library search. Also accepted as user_id. |
Reading the score
The response includes a cosine score. Lower means closer.
| Score | Meaning |
|---|---|
≤ 0.30 | Very confident match |
≤ 0.38 | Accepted match |
≤ 0.55 | Uncertain |
> 0.55 | Different person |
curl -X POST https://tareef.g4t.io/api/v1/verify \ -H "Authorization: Bearer frs_live_XXXXXX" \ -F "file=@photo.jpg"
curl -X POST https://tareef.g4t.io/api/v1/verify \ -H "Authorization: Bearer frs_live_XXXXXX" \ -F "file=@photo.jpg" \ -F "person_uuid=PERSON_UUID"
use Tareef\Laravel\Facades\Tareef; $result = Tareef::verify($request->file('selfie')); if ($result->matched) { return [ 'uuid' => $result->person->uuid, 'name' => $result->person->name, 'score' => $result->score, ]; }
Responses
200A match. Returnsuuid,name,scoreandsamples.200 not_foundBelow the threshold, or not in your library.200 not_identicalWithperson_uuid: a face was read, but it isn't that person.200 no_imagesWithperson_uuid: that person has no enrolled photos yet.200 no_faceNo detectable face in the query image.200 spoof_detectedLiveness is on and the photo looks like a screen or a print. Nothing is matched.404 person_not_foundNo person with thatperson_uuidin this application.429 quota_exceededThe monthly limit is reached.
Liveness check
Turn it on in your application settings to reject spoofed faces: a photo shown on another screen, or a print. It also applies to enrollment photos.
The query image is checked before any search runs. Every response then includes liveness: { checked, is_real, score, reason }.
- Refusal reasons are
spoof,low_confidenceandface_too_close. - On
face_too_close, ask the user to move back until head and shoulders are in frame. - Send the original camera frame. Screenshots, heavy compression and tight crops make real selfies harder to tell from spoofs.
Compare two faces
billableMeasures how similar two images are, with no enrollment and no library lookup. A good fit for KYC, such as matching a selfie to an ID photo.
Body parameters
| Name | Description |
|---|---|
file1required | First image. With liveness on, this must be the live capture. |
file2required | Second image, the reference. |
distance is cosine distance, lower is closer. similarity is 1 − distance. match applies the strictness configured for your application.
curl -X POST https://tareef.g4t.io/api/v1/compare \ -H "Authorization: Bearer frs_live_XXXXXX" \ -F "file1=@selfie.jpg" \ -F "file2=@id-photo.jpg"
{
"success": true,
"match": true,
"distance": 0.21,
"similarity": 0.79,
"threshold": 0.38
}
Responses
200matchis true or false, withdistanceandsimilarity.200 no_faceNo face in one or both images.no_face_insays which.200 spoof_detectedLiveness is on andfile1isn't a live capture. Onlyfile1is checked.
List people
Lists the people you have enrolled, newest first.
Query parameters
| Name | Type | Default | Description |
|---|---|---|---|
limitoptional | integer | 100 | Maximum rows returned. |
curl https://tareef.g4t.io/api/v1/people \
-H "Authorization: Bearer frs_live_XXXXXX"
Read and delete a person
Returns the person record and the paths of its reference images.
Permanently removes the person's embeddings and stored photos.
curl https://tareef.g4t.io/api/v1/people/UUID \
-H "Authorization: Bearer frs_live_XXXXXX"
curl -X DELETE https://tareef.g4t.io/api/v1/people/UUID \
-H "Authorization: Bearer frs_live_XXXXXX"
Rate limits and quotas
- Only verifications count against the monthly quota: identify and compare.
- Enrollment, reads and deletes are free.
- Quotas reset at 00:00 UTC on the 1st of each calendar month.
- Going over returns
429 quota_exceeded, withusedandlimitin the body.
| Plan | Price | Verifications | People |
|---|---|---|---|
| Free | Free | 100 / mo | 50 |
| Pro | 39,000 IQD/mo | 10,000 / mo | 5,000 |
| Business | 129,000 IQD/mo | 100,000 / mo | Unlimited |
Error codes
Every response includes a stable status string. Branch on it, not on the HTTP code alone.
| Status | HTTP | Meaning |
|---|---|---|
ok | 200 | Success. |
not_found | 200 / 404 | No matching person, or the UUID isn't in your library. |
no_face | 200 | No face detected in the image. |
spoof_detected | 200 / 422 | Liveness is on and the face is a photo of a screen or a print. |
liveness_unavailable | 200 / 422 | Liveness is on but couldn't run. Nothing was matched or enrolled. |
face_exists | 422 | The face is already enrolled. The existing UUID is returned. |
invalid | 422 | Malformed request body or missing required fields. |
unauthorized | 401 | Missing or revoked API key. |
quota_exceeded | 429 | Plan limit reached for the calendar month. |
upstream_error | 502 | The face recognition service was unreachable. |