DeepSwapAI Logo - Professional Face Swap Platform
Deep Swap AI
POST

/v1/batch-swap

Process multiple images in a single request. Perfect for e-commerce product photos, marketing campaigns, and high-volume automated workflows.

🛒

E-commerce

Generate model variations for product listings

📢

Marketing

Create localized ad creatives at scale

🎮

Gaming

Generate character variations

Request Body

ParameterTypeRequiredDescription
source_imagestringYesFace image to apply to all targets
target_imagesarrayYesArray of target image URLs/base64 (max 100)
qualitystringNo"standard", "high", "4k" (default: "high")
output_formatstringNo"png", "jpg", "webp" (default: "png")
webhook_urlstringNoReceive notification when batch completes

Batch Limits

PlanMax Images/BatchConcurrent Batches
Free101
Pro505
Enterprise100Unlimited

Code Examples

PyPython

import deepswapai

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

# Process batch of product images
target_images = [
    "https://cdn.yourstore.com/product1.jpg",
    "https://cdn.yourstore.com/product2.jpg",
    "https://cdn.yourstore.com/product3.jpg",
    # ... up to 100 images
]

job = client.batch_swap(
    source_image="path/to/model_face.jpg",
    target_images=target_images,
    quality="high",
    output_format="webp"
)

print(f"Batch Job ID: {job.id}")
print(f"Processing {len(target_images)} images...")

# Wait for all to complete
results = job.wait_for_completion(
    on_progress=lambda p: print(f"Progress: {p}%")
)

# Download all results
for i, result in enumerate(results):
    if result.success:
        result.download(f"output_{i}.webp")
    else:
        print(f"Failed: {result.error}")

JSJavaScript

import DeepSwapAI from '@deepswapai/sdk';

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

const targetImages = [
  'https://cdn.yourstore.com/product1.jpg',
  'https://cdn.yourstore.com/product2.jpg',
  'https://cdn.yourstore.com/product3.jpg',
];

const job = await client.batchSwap({
  sourceImage: 'https://example.com/model_face.jpg',
  targetImages,
  quality: 'high',
  webhookUrl: 'https://yoursite.com/batch-webhook'
});

// Or poll for results
const results = await job.waitForCompletion();
results.forEach((result, i) => {
  console.log(`Image ${i}: ${result.outputUrl}`);
});

Response

{
  "success": true,
  "job_id": "batch_abc123",
  "status": "processing",
  "total_images": 50,
  "completed": 0,
  "failed": 0,
  "estimated_time": 180,
  "credits_estimated": 50
}

Completed Response

{
  "success": true,
  "job_id": "batch_abc123",
  "status": "completed",
  "total_images": 50,
  "completed": 48,
  "failed": 2,
  "results": [
    {
      "index": 0,
      "success": true,
      "output_url": "https://cdn.deepswapai.com/batch/abc123_0.webp"
    },
    {
      "index": 1,
      "success": false,
      "error": "NO_FACE_DETECTED"
    }
    // ... more results
  ],
  "credits_used": 48
}

💡 Best Practices

  • Use webhooks for large batches instead of polling to reduce API calls
  • Pre-validate images - ensure all target images contain faces before submitting
  • Use consistent source images - high-quality, front-facing photos work best
  • Handle partial failures - some images may fail while others succeed

Related Endpoints