SDKs
TypeScript & Python SDK
LiveXFace provides official SDKs for TypeScript, Python, and Flutter. Each SDK offers typed request models, consistent error handling, and first-class support for multipart image uploads.
Installation
Shell
npm install livexface
# or
pnpm add livexfaceInitialize the Client
TypeScript
import { LiveXFace } from 'livexface'
const client = new LiveXFace({
apiKey: process.env.LIVEXFACE_API_KEY!,
baseUrl: 'https://api.livexface.com/api/v1', // optional
timeout: 30_000, // optional, ms
})Enroll a Face
TypeScript
import { readFileSync } from 'fs'
const face = await client.faces.register(collectionId, {
image: readFileSync('./alice.jpg'), // Buffer, Blob, or ArrayBuffer
externalId: 'employee-001',
metadata: { department: 'engineering' },
})
console.log(face.id) // UUID of the enrolled face
console.log(face.externalId) // 'employee-001'1:1 Verification
TypeScript
const result = await client.faces.verify(collectionId, {
image: readFileSync('./query.jpg'),
faceId: 'known-face-uuid',
threshold: 0.40,
})
console.log(result.match) // true | false
console.log(result.confidence) // 0.0 – 1.0
console.log(result.thresholdUsed) // effective threshold applied1:N Identification
TypeScript
const result = await client.faces.identify(collectionId, {
image: readFileSync('./query.jpg'),
topK: 3,
threshold: 0.45,
})
result.matches.forEach(m => {
console.log(m.externalId, m.confidence) // e.g. 'employee-001', 0.92
})Liveness Detection
TypeScript
const liveness = await client.faces.liveness(collectionId, {
image: readFileSync('./selfie.jpg'),
})
console.log(liveness.isLive) // true | false
console.log(liveness.livenessScore) // 0.0 – 1.0Batch Enrollment
TypeScript
const result = await client.faces.batchRegister(collectionId, [
{ externalId: 'emp-001', image: readFileSync('./alice.jpg') },
{ externalId: 'emp-002', image: readFileSync('./bob.jpg'),
metadata: { department: 'sales' } },
])
console.log(`${result.succeeded}/${result.succeeded + result.failed} enrolled`)Error Handling
TypeScript
import { LiveXFaceApiError, LiveXFaceNetworkError } from 'livexface'
try {
await client.faces.identify(collectionId, { image, topK: 3 })
} catch (err) {
if (err instanceof LiveXFaceApiError) {
console.error(err.code, err.message) // e.g. NO_FACE_DETECTED
} else if (err instanceof LiveXFaceNetworkError) {
console.error('Network failure:', err.message)
}
}Configuration reference
| Option | Default | Description |
|---|---|---|
| apiKey / api_key | — | Required. Your API key from the dashboard. |
| baseUrl / base_url | production URL | Override to point at a self-hosted instance. |
| timeout | 30 s | Request timeout. Increase for large batch uploads. |