DeepSwapAI Logo - Professional Face Swap Platform
Deep Swap AI
POST

/v1/image-swap

Swap faces in static images using AI-powered face detection and alignment. Supports up to 4K resolution output with professional-grade quality.

Request Body

ParameterTypeRequiredDescription
source_imagestringYesBase64-encoded image or URL of the face to use
target_imagestringYesBase64-encoded image or URL where face will be placed
output_formatstringNoOutput format: "png", "jpg", "webp" (default: "png")
qualitystringNo"standard", "high", "4k" (default: "high")
face_indexintegerNoWhich face to swap if multiple faces detected (0-indexed)

Code Examples

PyPython

import deepswapai

client = deepswapai.Client(api_key="YOUR_API_KEY")

# Using file paths
result = client.image_swap(
    source_image="path/to/source.jpg",
    target_image="path/to/target.jpg",
    quality="4k"
)

print(f"Output URL: {result.output_url}")
print(f"Processing time: {result.processing_time}ms")

# Download result
result.download("output.png")

JSJavaScript

import DeepSwapAI from '@deepswapai/sdk';

const client = new DeepSwapAI({ apiKey: 'YOUR_API_KEY' });

const result = await client.imageSwap({
  sourceImage: 'https://example.com/source.jpg',
  targetImage: 'https://example.com/target.jpg',
  quality: '4k'
});

console.log('Output URL:', result.outputUrl);

$cURL

curl -X POST https://api.deepswapai.com/v1/image-swap \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source_image": "https://example.com/source.jpg",
    "target_image": "https://example.com/target.jpg",
    "quality": "4k",
    "output_format": "png"
  }'

Response

{
  "success": true,
  "job_id": "job_abc123xyz",
  "output_url": "https://cdn.deepswapai.com/results/abc123.png",
  "output_format": "png",
  "resolution": "3840x2160",
  "processing_time": 2340,
  "faces_detected": 1,
  "credits_used": 1
}
FieldTypeDescription
output_urlstringURL to download the processed image (valid for 24 hours)
processing_timeintegerProcessing time in milliseconds
faces_detectedintegerNumber of faces detected in target image

Error Handling

Common Errors

  • NO_FACE_DETECTED - No face found in source or target image
  • IMAGE_TOO_LARGE - Image exceeds maximum size (50MB)
  • INVALID_FORMAT - Unsupported image format

Related Endpoints