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 TypeCredits Required
Single Face Swap5 credits per image
Multiple Face Swap10 credits per image

Endpoint

POST /api/aigc/task/submit

Request Headers

Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

Request Parameters

ParameterTypeRequiredDescription
aigc_typestringMust be "image_face_swap" for image face swapping
callback_urlstringURL endpoint to receive processing results via POST
task_listarrayArray of face swap tasks (supports batch processing)
task_list[].additional_paramsobjectTask-specific parameters
task_list[].additional_params.target_image_urlstringURL of the target image (Image B where face will be placed)
task_list[].additional_params.target_face_urlstringURL of the source face image (Face A to be swapped onto Image B)
task_list[].callback_paramsobjectCustom 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 request
  • creation_id: Unique identifier grouping all tasks in the request
  • task_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 TypeStandardWith Face Enhancement
Single Face Swap5 credits/second10 credits/second
Multiple Face Swap10 credits/second20 credits/second

Endpoint

POST /api/aigc/task/submit

Request Parameters

ParameterTypeRequiredDescription
aigc_typestring"single_video_face_swap" for one face, "multiple_video_face_swap" for multiple faces
callback_urlstringURL endpoint to receive processing results via POST
task_listarrayArray of video face swap tasks
task_list[].additional_paramsobjectTask-specific parameters
task_list[].additional_params.target_video_urlstringURL of the video file to process
task_list[].additional_params.face_enhancenumberHD face enhancement: 1 = enabled, 0 = disabled
task_list[].additional_params.start_trim_secnumberStart time for face swap processing (in seconds)
task_list[].additional_params.end_trim_secnumberEnd time for face swap processing (in seconds)
task_list[].additional_params.face_swap_listarrayArray of face swap rules
task_list[].additional_params.face_swap_list[].srcstringURL of the source face photo to use
task_list[].additional_params.face_swap_list[].targetstringURL of target face in video frame. If empty, system auto-selects
task_list[].callback_paramsobjectCustom 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:

  1. Process Start Callback (process_status = 1) – Sent immediately when the AI starts processing your task.
  2. 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

FieldTypeDescription
task_idstringUnique task identifier
creation_idstringRequest batch identifier
start_timenumberProcessing start timestamp
end_timenumberProcessing end timestamp (when process_status = 2)
cost_timenumberTotal processing duration
result_codenumberinference result codes. success: 1, failure: -1 (This field value is valid only when process_status=2)
error_infostringError description (if failed)
error_codestringError code (if failed)
process_statusnumber1 = processing started, 2 = processing completed
result_listarrayArray of result urls
request_contextobjectYour callback_params echoed back

Webhook Retry Logic

  • Your endpoint must return HTTP 200 to 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

CodeDescription
100000Success
100010Invalid parameters
100030Access denied (authentication failed)
100040Insufficient credits balance
100099Unknown error

Best Practices

Image Quality Requirements

  • • 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

  1. Batch Processing: Submit multiple tasks in one request to reduce overhead
  2. Video Trimming: Use start_trim_sec and end_trim_sec to process only necessary segments
  3. Face Enhancement: Enable only when high quality is essential (doubles credit cost)
  4. Webhook Reliability: Implement idempotency using task_id to handle duplicate callbacks

FAQ

How long does processing take?
Image face swaps typically complete in 5-15 seconds. Video processing time depends on duration and complexity, averaging 1-2x real-time (e.g., a 10-second video takes 10-20 seconds to process).
What video formats are supported?
Common formats including MP4, MOV, AVI, and WebM are supported. We recommend MP4 with H.264 codec for best compatibility.
Can I swap multiple faces in a single image?
Yes, use the multiple face swap option (10 credits) to replace multiple faces in one image. Submit multiple face pairs in the face_swap_list.
How long are result URLs valid?
Result URLs in webhook callbacks are valid for 2 hours. Download and store results in your own infrastructure promptly.
What if my webhook endpoint is down?
The system retries up to 4 times with exponential backoff (5s, 30s, 120s, 300s). Ensure your endpoint has proper monitoring and error handling.

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