Face Swap API – Fast, High-Quality Face Replacement for Images & Videos
Overview
The Face Swap API enables seamless face replacement in both images and videos using advanced AI technology. Whether you're building a photo editor, video creation tool, or social media application, our API provides production-ready face swapping capabilities with high-quality results.
Key Features
- Image Face Swap: Swap single or multiple faces in static images
- Video Face Swap: Replace faces in video content with frame-by-frame precision
- Batch Processing: Submit multiple tasks in a single API request
- HD Enhancement: Optional face enhancement for professional-quality results
- Flexible Face Selection: Automatic or manual face targeting in videos
Authentication
All API requests require authentication using an API key. Include your API key in the request header:
Authorization: Bearer YOUR_API_KEY
API Host: https://us-center.deep-api.com
🔑 Getting Your API Key
Contact customer support to obtain your API key and start integrating face swap capabilities into your application.
Image Face Swap API
Pricing
| Service Type | Credits Required |
|---|---|
| Single Face Swap | 5 credits per image |
| Multiple Face Swap | 10 credits per image |
Endpoint
POST /api/aigc/task/submit
Request Headers
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
aigc_type | string | ✅ | Must be "image_face_swap" for image face swapping |
callback_url | string | ✅ | URL endpoint to receive processing results via POST |
task_list | array | ✅ | Array of face swap tasks (supports batch processing) |
task_list[].additional_params | object | ✅ | Task-specific parameters |
task_list[].additional_params.target_image_url | string | ✅ | URL of the target image (Image B where face will be placed) |
task_list[].additional_params.target_face_url | string | ✅ | URL of the source face image (Face A to be swapped onto Image B) |
task_list[].callback_params | object | ❌ | Custom parameters returned in webhook callback |
Response Format
{
"code": 100000,
"message": "Request Success",
"data": {
"credits_consumed": 5,
"creation_id": "acaaf3ec58b14e98a22f7506b8736421",
"task_id_list": [16224172]
}
}
Response Fields:
code: Status code (100000 = success)credits_consumed: Total credits used for this requestcreation_id: Unique identifier grouping all tasks in the requesttask_id_list: Array of task IDs in submission order
Code Example
curl --location --request POST \
'https://us-center.deep-api.com/api/aigc/task/submit' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"aigc_type": "image_face_swap",
"callback_url": "https://your-domain.com/result/callback",
"task_list": [
{
"additional_params": {
"target_image_url": "https://your-storage.com/target-image.jpg",
"target_face_url": "https://your-storage.com/source-face.png"
},
"callback_params": {
"user_id": "12345",
"custom_data": "any_value"
}
}
]
}'
Video Face Swap API
Pricing
| Service Type | Standard | With Face Enhancement |
|---|---|---|
| Single Face Swap | 5 credits/second | 10 credits/second |
| Multiple Face Swap | 10 credits/second | 20 credits/second |
Endpoint
POST /api/aigc/task/submit
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
aigc_type | string | ✅ | "single_video_face_swap" for one face, "multiple_video_face_swap" for multiple faces |
callback_url | string | ✅ | URL endpoint to receive processing results via POST |
task_list | array | ✅ | Array of video face swap tasks |
task_list[].additional_params | object | ✅ | Task-specific parameters |
task_list[].additional_params.target_video_url | string | ✅ | URL of the video file to process |
task_list[].additional_params.face_enhance | number | ✅ | HD face enhancement: 1 = enabled, 0 = disabled |
task_list[].additional_params.start_trim_sec | number | ✅ | Start time for face swap processing (in seconds) |
task_list[].additional_params.end_trim_sec | number | ✅ | End time for face swap processing (in seconds) |
task_list[].additional_params.face_swap_list | array | ✅ | Array of face swap rules |
task_list[].additional_params.face_swap_list[].src | string | ✅ | URL of the source face photo to use |
task_list[].additional_params.face_swap_list[].target | string | ❌ | URL of target face in video frame. If empty, system auto-selects |
task_list[].callback_params | object | ❌ | Custom parameters returned in webhook callback |
⚠️ Important Note
For single-person video face swapping, only one face swap rule is supported in the face_swap_list array.
Response Format
{
"code": 100000,
"message": "Request Success",
"data": {
"credits_consumed": 100,
"creation_id": "3fe766593eed425e83bf7a36b7321c31",
"task_id_list": [16222903]
}
}
Code Example
curl --location --request POST \
'https://us-center.deep-api.com/api/aigc/task/submit' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"aigc_type": "multiple_video_face_swap",
"callback_url": "https://your-domain.com/callback",
"task_list": [
{
"additional_params": {
"target_video_url": "https://your-storage.com/video.mp4",
"face_swap_list": [
{
"src": "https://your-storage.com/face1.jpg",
"target": "https://your-storage.com/target1.jpg"
},
{
"src": "https://your-storage.com/face2.jpg",
"target": "https://your-storage.com/target2.jpg"
}
],
"face_enhance": 1,
"start_trim_sec": 0.0,
"end_trim_sec": 5.875
},
"callback_params": {
"project_id": "abc123"
}
}
]
}'
Webhook Callbacks
Upon task completion, results are sent to your callback_url via POST request.
⚠️ Important:
Each task triggers two separate callbacks:
- Process Start Callback (
process_status = 1) – Sent immediately when the AI starts processing your task.- Process Complete Callback (
process_status = 2) – Sent when the task finishes (successfully or failed).You should handle both callbacks properly:
- Use the start callback to update UI or mark task as “in progress”
- Use the complete callback to retrieve results and finalize the task
- Avoid treating “start” callback as a completion event
Webhook Request Structure
| Field | Type | Description |
|---|---|---|
task_id | string | Unique task identifier |
creation_id | string | Request batch identifier |
start_time | number | Processing start timestamp |
end_time | number | Processing end timestamp (when process_status = 2) |
cost_time | number | Total processing duration |
result_code | number | inference result codes. success: 1, failure: -1 (This field value is valid only when process_status=2) |
error_info | string | Error description (if failed) |
error_code | string | Error code (if failed) |
process_status | number | 1 = processing started, 2 = processing completed |
result_list | array | Array of result urls |
request_context | object | Your callback_params echoed back |
Webhook Retry Logic
- Your endpoint must return HTTP
200to confirm receipt - Non-200 responses trigger up to 4 retries at intervals: 5s, 30s, 120s, 300s
- Implement proper error handling to receive callbacks reliably
Status Codes
| Code | Description |
|---|---|
| 100000 | Success |
| 100010 | Invalid parameters |
| 100030 | Access denied (authentication failed) |
| 100040 | Insufficient credits balance |
| 100099 | Unknown error |
Best Practices
Image Quality Requirements
✓ Recommended
- • Clear, well-lit faces
- • Forward-facing angles
- • High resolution
- • Minimal occlusion
✗ Avoid
- • Blurry or low-res images
- • Extreme side angles
- • Heavily shadowed faces
- • Sunglasses or masks
Performance Optimization
- Batch Processing: Submit multiple tasks in one request to reduce overhead
- Video Trimming: Use
start_trim_secandend_trim_secto process only necessary segments - Face Enhancement: Enable only when high quality is essential (doubles credit cost)
- Webhook Reliability: Implement idempotency using
task_idto handle duplicate callbacks
FAQ
How long does processing take?
What video formats are supported?
Can I swap multiple faces in a single image?
How long are result URLs valid?
What if my webhook endpoint is down?
Use Cases
Social Media Applications
Create engaging content with face swap filters and effects for viral social media posts.
Entertainment & Gaming
Build avatar systems, character customization tools, or entertainment apps with real-time face swapping.
Video Production
Automate face replacement in video editing workflows for content creators and production studios.
Marketing & Advertising
Generate personalized marketing materials with customer faces in promotional content.
Support
Need help integrating the Face Swap API? Contact our technical support team for:
- API key provisioning
- Integration assistance
- Credit balance inquiries
- Technical troubleshooting
API Version: v1
Last Updated: October 2025