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
Header bắt buộc cho mọi request:
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). |
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 |
© AHV AI Orchestrator • Documentation