← Back to index Logout

title: Cluster Agent API version: 1.0 date: 2026-10-25 author: Core Team status: Active


Cluster Agent

Asynchronous face clustering agent that automatically groups similar faces into identities. Runs as a background job.

POST /api/v1/file/:file_uuid/cluster-agent

Auth: Required Scope: file-level

Trigger asynchronous face clustering for a file. Returns immediately with a job ID. Clustering runs in the background.

Path Parameters

Parameter Type Description
file_uuid string File UUID (32-char hex)

Request Parameters

Field Type Required Default Description
confirm boolean Yes false Must be true to trigger clustering
min_confidence float No 0.6 Minimum face confidence to include
algorithm string No "dbscan" Clustering algorithm ("dbscan", "kmeans")

Example

curl -X POST "$API/api/v1/file/$FILE_UUID/cluster-agent" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"confirm": true, "min_confidence": 0.6}'

Response (202 Accepted)

{
  "success": true,
  "job_id": "cluster_abc123",
  "file_uuid": "3a6c1865...",
  "status": "queued",
  "message": "Cluster job queued for processing"
}
Field Type Description
success boolean Always true on 202
job_id string Job ID for status tracking
file_uuid string File UUID
status string Job status ("queued", "running", "completed", "failed")
message string Human-readable status

Error Responses

HTTP When
400 confirm not set to true
404 File not found
409 Job already running for this file
401 Missing or invalid API key

GET /api/v1/cluster-job/:job_id

Auth: Required Scope: job-level

Get status of a cluster job. Returns progress, statistics, and results if completed.

Path Parameters

Parameter Type Description
job_id string Job ID returned from trigger endpoint

Example

curl -s "$API/api/v1/cluster-job/cluster_abc123" -H "X-API-Key: $KEY"

Response (200)

{
  "job_id": "cluster_abc123",
  "file_uuid": "3a6c1865...",
  "status": "completed",
  "progress": {
    "total_faces": 1523,
    "processed": 1523,
    "percentage": 100
  },
  "result": {
    "clusters_found": 12,
    "identities_created": 8,
    "identities_updated": 4
  },
  "started_at": "2026-10-25T10:00:00Z",
  "completed_at": "2026-10-25T10:05:30Z"
}
Field Type Description
job_id string Job ID
file_uuid string File UUID
status string "running", "completed", "failed", "cancelled"
progress object Progress information
result object Final results (if completed)
error string Error message (if failed)
started_at string ISO 8601 timestamp
completed_at string ISO 8601 timestamp (if completed)

DELETE /api/v1/cluster-job/:job_id

Auth: Required Scope: job-level

Cancel a running cluster job. Cannot cancel completed or failed jobs.

Path Parameters

Parameter Type Description
job_id string Job ID

Example

curl -X DELETE "$API/api/v1/cluster-job/cluster_abc123" -H "X-API-Key: $KEY"

Response (200)

{
  "success": true,
  "job_id": "cluster_abc123",
  "status": "cancelled",
  "message": "Job cancelled successfully"
}

Clustering Process

How It Works

  1. Face Collection: Gather all face detections from the file
  2. Embedding Extraction: Get face embeddings (512-dim vectors)
  3. Similarity Clustering: Group similar faces using DBSCAN
  4. Identity Assignment: Create or update identities for clusters
  5. Face Binding: Bind faces to their cluster identity

Clustering Algorithm

DBSCAN Parameters: - eps: 0.3 (distance threshold) - min_samples: 5 (minimum cluster size)

Quality Metrics: - Intra-cluster similarity: Average pairwise similarity within cluster - Inter-cluster separation: Average distance to nearest cluster


Use Cases

1. Automatic Identity Creation

# After processing, trigger clustering
curl -X POST "$API/api/v1/file/$FILE_UUID/cluster-agent" \
  -H "X-API-Key: $KEY" \
  -d '{"confirm": true}'

2. Monitor Clustering Progress

# Poll job status
curl -s "$API/api/v1/cluster-job/$JOB_ID" -H "X-API-Key: $KEY" | jq '.status'

3. Cancel Slow Clustering

# If clustering takes too long
curl -X DELETE "$API/api/v1/cluster-job/$JOB_ID" -H "X-API-Key: $KEY"

Performance

File Size Face Count Processing Time
10 min video 500 faces ~30 seconds
30 min video 1500 faces ~2 minutes
90 min video 4500 faces ~8 minutes

Notes: - Processing time scales linearly with face count - Uses in-memory job registry (cleared on server restart) - Concurrent jobs are supported but resource-intensive


Error Handling

Error Cause Solution
400 Bad Request confirm not set Add "confirm": true to request body
404 Not Found File not found Verify file_uuid
409 Conflict Job already running Wait for current job to complete or cancel it
500 Internal Error Clustering failed Check server logs for details

Version History

Version Date Changes
1.0 2026-10-25 Initial documentation