System Overview
Hệ thống AI Orchestrator cung cấp API để xử lý các tác vụ AI nặng (FaceSwap, Video Gen, Upscale, Editing) thông qua cơ chế Async Queue.
Hỗ trợ:
Faceswap (Single/Multi)
Faceswap Video
AHV Image/Video
GG Image
CX Image
Upscale & Beauty
Remove Obj
Scan Obj
Recommended Workflow
- 1. Client gửi
POST /v1/jobskèmwebhook_url. - 2. Server trả về
job_idvà trạng tháiqueued. - 3. Client tiếp tục làm việc khác.
- 4. Khi hoàn thành, Server gọi
POST webhook_urltrả kết quả.
Authentication
X-API-Key: your_secret_key
1. Async Jobs API
Endpoint: POST /v1/jobs. Hỗ trợ retry, queue management và webhook notification.
Create FaceSwap Job (Image)
Mode 1: Single Face
curl -X POST "{{API_BASE}}/v1/jobs" \
-H "X-API-Key: {{API_KEY}}" \
-H "Content-Type: application/json" \
-d '{
"task": "faceswap",
"webhook_url": "https://your-site.com/webhook",
"payload": {
"source_url": "https://example.com/face.jpg",
"target_url": "https://example.com/body.jpg",
"upscale": 1,
"max_side": 1280
}
}'
Mode 2: Multi-Face
curl -X POST "{{API_BASE}}/v1/jobs" \
-H "X-API-Key: {{API_KEY}}" \
-H "Content-Type: application/json" \
-d '{
"task": "faceswap_multi",
"webhook_url": "https://your-site.com/webhook",
"payload": {
"source_urls": [
"https://ex.com/face1.jpg",
"https://ex.com/face2.jpg"
],
"target_url": "https://example.com/group.jpg",
"swap_faces_index": [0, 1],
"target_faces_index": [2, 0],
"sharpen": 0.5
}
}'
| Param | Type | Desc |
|---|---|---|
target_url | string | Required. Ảnh đích. |
source_url | string | Ảnh chứa mặt gốc (1 mặt). |
source_urls | array | Mảng ảnh chứa mặt (Nhiều mặt). |
swap_faces_index | array | Index mặt trong nguồn cần lấy. |
target_faces_index | array | Index mặt trong đích cần thay. |
max_side | int | Resize cạnh lớn nhất (Def: 1080). |
upscale | 0/1 | Bật Upscale sau khi swap (Def: 1). |
sharpen | float | Độ sắc nét (e.g. 0.12). |
max_faces | int | Giới hạn số mặt xử lý (Def: 0 - All). |
/v1/jobs
task: nsfw_check
Kiểm tra ảnh có chứa nội dung 18+/NSFW hay không. Trả về điểm NSFW score và nhãn safe/nsfw.
curl -X POST "{{API_BASE}}/v1/jobs" \
-H "X-API-Key: {{API_KEY}}" \
-H "Content-Type: application/json" \
-d '{
"task": "nsfw_check",
"webhook_url": "https://your-site.com/webhook",
"payload": {
"image_url": "https://example.com/photo.jpg",
"strict": "medium"
}
}'
| Param | Type | Desc |
|---|---|---|
image_url | string * | URL ảnh cần kiểm tra (bắt buộc). |
strict | string | Mức độ lọc: low (0.75), medium (0.55), high (0.35). Def: low. |
threshold | float | Ngưỡng tùy chỉnh 0.0-1.0. Nếu set sẽ ghi đè strict. |
Response result:
{
"nsfw_score": 0.0001,
"is_nsfw": false,
"threshold": 0.75,
"strict": "low",
"label": "safe",
"elapsed": 0.098
}
| Strict Level | Threshold | Mô tả |
|---|---|---|
low | 0.75 | Mặc định, chỉ block rõ ràng |
medium | 0.55 | Lọc vừa phải |
high | 0.35 | Lọc gắt, nhạy cảm cao |
/v1/nsfw-check
Upload file trực tiếp
Endpoint hỗ trợ upload file ảnh trực tiếp (multipart/form-data) hoặc gửi URL. Tự động upload → tạo job → trả job_id.
Upload file:
curl -X POST "{{API_BASE}}/v1/nsfw-check" \
-H "X-API-Key: {{API_KEY}}" \
-F "file=@/path/to/image.jpg" \
-F "strict=medium"
Gửi URL:
curl -X POST "{{API_BASE}}/v1/nsfw-check" \
-H "X-API-Key: {{API_KEY}}" \
-F "image_url=https://example.com/photo.jpg" \
-F "strict=low"
| Param | Type | Desc |
|---|---|---|
file | file | Upload ảnh trực tiếp (JPG/PNG/WEBP/GIF, max 10MB). Ưu tiên nếu có. |
image_url | string | URL ảnh (dùng nếu không upload file). |
strict | string | Mức độ lọc: low, medium, high. Def: low. |
threshold | float | Ngưỡng tùy chỉnh 0.0-1.0. |
webhook_url | string | URL nhận kết quả qua webhook. |
Response:
{
"ok": true,
"job_id": "abc123...",
"status": "queued",
"image_url": "https://...uploaded-file.jpg",
"predict_time": 5
}
💡 Sau đó dùng GET /v1/jobs/{job_id} để lấy kết quả, hoặc nhận qua webhook.
2. Webhook & Job Status
Webhook Payload: succeeded
{
"event": "job.finished",
"event_id": "f03675fc03334822be22b98ee9215c1d",
"ts": "2026-02-04T18:04:19.463754+00:00",
"job_id": "d1142818265748d9914053dafc20dd98",
"task": "upscale",
"status": "succeeded",
"progress": 100,
"ok": true,
"created_at": "2026-02-04T18:04:13.773524+00:00",
"created_at_ms": 1770228253773,
"queued_at": "2026-02-04T18:04:13.773524+00:00",
"queued_at_ms": 1770228253773,
"started_at": "2026-02-04T18:04:14.264808+00:00",
"started_at_ms": 1770228254264,
"finished_at": "2026-02-04T18:04:19.462901+00:00",
"finished_at_ms": 1770228259462,
"duration": 5.198093,
"predict_time": 3,
"eta_utc": "2026-02-04T18:04:16.773638+00:00",
"result": {
"ok": true,
"status": "succeeded",
"url": "http://15.235.200.66:2022/files/3c3da5ddac6a4c5081d46d829d168cb3.jpg",
"filename": "3c3da5ddac6a4c5081d46d829d168cb3.jpg",
"meta": {
"width": 507,
"height": 678,
"backend": "UPVN1-1"
}
},
"error": null,
"predictTime": 3
}
Job Lifecycle Status
Click vào badge để xem mẫu Webhook JSON tương ứng.
| queued | Đang chờ trong hàng đợi. |
| running | Backend đang xử lý. |
| succeeded | Hoàn thành, có result.url. |
| failed | Lỗi kỹ thuật hoặc timeout. |
| rejected | Từ chối (NSFW blocked). |
3. API Reference
Management Endpoints
GET /stats |
Lấy danh sách các jobs gần nhất. |
GET /v1/jobs/{id} |
Polling trạng thái Job (nếu không dùng Webhook). |
DELETE /tasks/{id} |
Xóa job khỏi hệ thống. |
GET /diag/backends |
Xem trạng thái tải (slots/concurrency) của các node GPU. |
Direct Blocking Endpoints
Gọi trực tiếp, giữ kết nối cho đến khi xong. Payload giống hệt payload của Async Job.
POST /faceswap | Xử lý FaceSwap Ảnh |
POST /faceswap/video | Xử lý FaceSwap Video |
POST /upscale | Upscale & Restore |
POST /ahv/image | Gen Ảnh (Text2Img, Img2Img) |
POST /ahv/video | Video Gen (Veo 3.1 T2V/I2V) |
POST /gg/image | GG Image Gen (Imagen 4) |
POST /cx/image | CX Image Gen (GPT-5.4 Image) |
POST /remove-object | Xóa vật thể (Mask/Prompt) |
POST /scan-objects | Detect vật thể (JSON) |
POST /remove-background | Tách nền |