Quick start
Submit a photo task, then poll it
- Verify the account email. New generation requests require a verified account.
- Complete one credit purchase. API keys require at least one order in PAID or COMPLETED state; reward and trial credits are web-only.
- Create an API key. Use the key manager below and save the key when it is shown. Each account can hold at most three keys.
- Submit multipart media. Keep the returned
taskId. - Poll the same route. Stop at
COMPLETED,FAILED, orCANCELLED.
1. Create the task
curl --request POST 'https://deepswapai.com/api/ai-tasks' \
--header 'Authorization: Bearer $DEEPSWAPAI_API_KEY' \
--form 'sourceImage=@identity.jpg' \
--form 'targetImage=@scene.jpg'
Accepted response
{
"taskId": "b6de3ea5-52ef-41a5-8a4b-276cf548dd9c",
"status": "PENDING"
}
2. Poll the task
curl --get 'https://deepswapai.com/api/ai-tasks' \
--header 'Authorization: Bearer $DEEPSWAPAI_API_KEY' \
--data-urlencode 'taskId=b6de3ea5-52ef-41a5-8a4b-276cf548dd9c'
Current completion contract: polling is supported. Webhook callbacks and official language SDKs are not currently published.
Designing the orchestration around this contract? Use the face swap pipeline architecture guide for validation, task states, retries, settlement, observability, and retention boundaries.
Runnable server examples
Start with Node.js 20 or Python
Both examples create one photo task and poll the documented endpoint until a terminal state. Set DEEPSWAPAI_API_KEY, keep the key on the server, and replace the two local file names. Python requires the requests package; the Node.js example uses built-in web APIs.
import { openAsBlob } from 'node:fs';
const apiKey = process.env.DEEPSWAPAI_API_KEY;
if (!apiKey) throw new Error('Set DEEPSWAPAI_API_KEY first.');
async function apiRequest(path, options = {}) {
const response = await fetch(`https://deepswapai.com${path}`, {
...options,
headers: {
Authorization: `Bearer ${apiKey}`,
Accept: 'application/json',
...options.headers,
},
});
const payload = await response.json();
if (!response.ok) throw new Error(payload.error || 'API request failed');
return payload;
}
const form = new FormData();
form.append('sourceImage', await openAsBlob('identity.jpg'), 'identity.jpg');
form.append('targetImage', await openAsBlob('scene.jpg'), 'scene.jpg');
const task = await apiRequest('/api/ai-tasks', { method: 'POST', body: form });
const terminal = new Set(['COMPLETED', 'FAILED', 'CANCELLED']);
let state = task;
while (!terminal.has(state.status)) {
await new Promise((resolve) => setTimeout(resolve, 3000));
state = await apiRequest(`/api/ai-tasks?taskId=${encodeURIComponent(task.taskId)}`);
}
console.log(state);
import os
import time
import requests
api_key = os.environ["DEEPSWAPAI_API_KEY"]
base_url = "https://deepswapai.com"
headers = {"Authorization": f"Bearer {api_key}", "Accept": "application/json"}
with open("identity.jpg", "rb") as source, open("scene.jpg", "rb") as target:
response = requests.post(
f"{base_url}/api/ai-tasks",
headers=headers,
files={"sourceImage": source, "targetImage": target},
timeout=60,
)
response.raise_for_status()
task = response.json()
terminal = {"COMPLETED", "FAILED", "CANCELLED"}
state = task
while state["status"] not in terminal:
time.sleep(3)
response = requests.get(
f"{base_url}/api/ai-tasks",
headers=headers,
params={"taskId": task["taskId"]},
timeout=30,
)
response.raise_for_status()
state = response.json()
print(state)
Support boundary: these are plain HTTP examples and a Postman collection, not official SDKs. The OpenAPI file remains the machine-readable source of truth.
API key manager
Create and revoke keys without leaving the reference
Key management uses your signed-in DeepSwapAI account session. Creating a key requires a verified email and at least one PAID or COMPLETED credit order. Reward and trial credits cannot be automated through API keys. Each account can hold at most three keys; a new secret is displayed once. Store it in a server-side secret manager; never place it in browser code, mobile binaries, public repositories, logs, or support messages.
Not connected.
Sign in to manage keys
Workflow matrix
Choose the endpoint that matches the output unit
| Workflow | POST and GET path | Credit unit | Primary limits |
|---|---|---|---|
| Photo | /api/ai-tasks | 3 per task | 30 MB per image |
| Batch photo | /api/ai-tasks/batch-face-swap | 3 per generated output | 20 images, 30 MB each, 95 MB total |
| Mapped group photo | /api/ai-tasks/multi-face-swap | 3 per replacement face | 10 faces, 30 MB each, 95 MB total |
| Video | /api/ai-tasks/video | Face-only with scene preservation: 1/s, min 5 at 1080p | 600 seconds, 95 MB combined upload |
| GIF / short clip | /api/ai-tasks/gif | 1/s, 5 minimum | 30 seconds, 95 MB target |
API pricing in USD
What does one face swap API generation cost?
The API uses the same one-time credit balance as the browser workflows. The USD figures below are credit-value equivalents: workflow credits multiplied by the selected package price and divided by that package's credits. Checkout sells complete packages, not individual generation requests, and the live credit-plan endpoint is the current price source.
3-credit image unit
$0.096-$0.150 for one photo task, batch output, or mapped group face.
1080p video minimum
5 credits, equivalent to $0.160-$0.250. Each rounded-up second uses 1 credit.
60-second video
60 credits at 1080p, equivalent to $1.92-$3.00. The workflow changes the face only and preserves the scene.
GIF minimum
5 credits, equivalent to $0.160-$0.250. Each rounded-up second uses 1 credit.
| Billable example | Credits | Basic $9.99 / 200 | Standard $24.99 / 700 | Premium $79.99 / 2500 |
|---|---|---|---|---|
| One photo task, batch output, or mapped group face | 3 | $0.150 | $0.107 | $0.096 |
| 60-second face-only video at 1080p | 60 | $3.00 | $2.14 | $1.92 |
| 10-second GIF | 10 | $0.50 | $0.36 | $0.32 |
How to use these figures: compare the task length first, then the package. A 60-second face-only task uses 60 credits at the fixed highest 1080p tier. Taxes, payment-currency conversion, and the final checkout total are not included in the equivalent. Use the exact task calculator and current package table before funding an integration.
Source-checked API contract landscape
Compare six published face swap API contracts
The table normalizes what each provider currently publishes about media inputs, request transport, multiple-face or batch behavior, completion, client assets, machine-readable contracts, pricing units, and output availability. It does not turn unlike credit, frame, second, resolution, face-count, or subscription units into a false price ranking.
API records
Six provider contracts reviewed under the same field definitions.
Official source URLs
API references, pricing pages, integration guides, and retention statements.
Output tests
No generation, quality, speed, latency, reliability, or safety ranking.
| Provider | Media and input | Mapping and completion | Clients and specification | Published pricing and output window |
|---|---|---|---|---|
| DeepSwapAIReviewed | Photo, batch photo, mapped group photo, video, and GIF or short clip.Multipart file uploads over HTTPS. | Up to 20 photos per batch and up to 10 explicitly mapped faces in one group photo. Video applies one reference to the primary on-camera person.Create returns a taskId; poll GET on the matching workflow endpoint. No webhook callback is published. | Runnable Node.js 20 and Python HTTP examples plus a Postman collection. No official language SDK is published.Public OpenAPI 3.1 document and Postman collection. | 3 credits per photo output or mapped face; face-only video with scene preservation costs 1 credit per rounded-up second with a 5-credit minimum at the fixed highest 1080p tier; GIF costs 1 credit per second with a 5-credit minimum. Credits are sold in one-time packs.Uploads and generated media are removed from DeepSwapAI servers within 24 hours. |
| Magic HourReviewed | Photo and video; GIF is accepted on the video path; multiple-face mappings are documented.Magic Hour upload paths or supported public media URLs. | Multiple source-to-target face mappings are documented. A single multi-file photo-batch request contract was not confirmed in the reviewed sources.Polling and signed webhook events are documented. | Official Python, Node.js or TypeScript, Go, and Rust SDKs are documented.Public API reference is available; a downloadable consolidated OpenAPI file was not confirmed in the reviewed sources. | Face Swap Photo is published at 5 credits. Video usage is estimated and finalized from rendered frames. Subscription and usage-based billing options are documented.Files uploaded to Magic Hour storage are documented as automatically deleted after 7 days. |
| PiAPIReviewed | Image and MP4 video face swap.Image URLs or base64 strings for image tasks; media URLs for video tasks. | Image tasks replace the largest detected face. Video tasks document indexed single- or multiple-face mappings. A multi-file image batch contract was not confirmed.Asynchronous task ID with task retrieval; optional webhook configuration is present in the image task contract. | A first-party Postman tutorial and generated request examples are available. An official maintained language SDK was not confirmed.The image reference exposes an OpenAPI 3.0.1 operation definition. A standalone consolidated specification was not confirmed. | The image endpoint reference publishes $0.01 per generation and the video reference publishes $0.004 per frame. The provider face swap product page separately publishes $0.02 per call; this official-source conflict is unresolved.The output-storage documentation publishes a 3-day storage period for API output images. A separate video-output period was not confirmed. |
| FacemintReviewed | Image, GIF, and video face swap.Media URLs in JSON task requests. | Video pricing documents face-count, resolution, and enhancement multipliers. A dedicated multi-file batch request was not confirmed.Task creation, task information, cancellation, and callbacks are documented. | HTTP and cURL examples are published. An official maintained language SDK was not confirmed.A downloadable OpenAPI or equivalent machine-readable specification was not confirmed in the reviewed sources. | $0.002 per image, $0.002 per 100 KB of GIF input, and a $0.0045 per second base video rate before documented face-count, resolution, and enhancement multipliers. The pricing page says callbacks are free.A fixed upload or output retention window was not confirmed in the reviewed API and pricing pages. |
| SupaworkReviewed | Single- and multiple-face image and video tasks.Public media URLs in JSON requests. | Single- and multiple-face modes are documented, and task_list supports several tasks in one request.A callback URL is required. The documentation describes callback retries and status payloads. | HTTP and cURL examples are published. An official maintained language SDK was not confirmed.A downloadable OpenAPI or equivalent machine-readable specification was not confirmed in the reviewed sources. | Image tasks publish 5 credits for single-face and 10 credits for multiple-face. Video tasks publish 5 to 20 credits per second depending on single or multiple face and enhancement.The documented result URL is valid for 2 hours. |
| WaveSpeedAIReviewed | Video face swap for the reviewed model.Public face-image and video URLs in a JSON prediction request. | A target face index selects one detected face for a run. A multi-file batch or several mapped replacements in one request was not confirmed.Create returns a prediction ID; poll the prediction endpoint for status and output. | cURL, Node.js, and Python request examples are published. Those examples were not classified as official maintained SDKs.A downloadable OpenAPI or equivalent machine-readable specification was not confirmed in the reviewed sources. | $0.01 per second with a 5-second minimum for the reviewed video face swap model.A fixed output retention period was not confirmed in the reviewed model and API pages. |
Official sources and row notes
Open each provider record to inspect the exact first-party pages used. Product behavior and pricing can change after the row review date.
DeepSwapAI5 official sources
First-party API reference, machine-readable contract, client collection, pricing, and privacy policy. No generation request was made for this review.
Magic Hour5 official sources
The photo and video paths use different units. Product, SDK, event, and storage statements are preserved without inferring an output-quality or speed result.
PiAPI5 official sources
Both official image-price statements are retained. Video cost is frame-based and cannot be compared directly with a per-call image amount.
Facemint2 official sources
The video base rate changes with published multipliers, so it is not a final representative task price by itself.
Supawork2 official sources
Image and video credit units are provider-specific; video enhancement and multiple-face choices change the rate.
WaveSpeedAI2 official sources
The reviewed model publishes a 10-minute maximum. No generation, latency, reliability, or output-quality test was run.
Photo
POST /api/ai-tasks
Send sourceImage as the identity reference and targetImage as the scene to preserve. Optional numeric fields are faceRestoreVisibility and restoreVisibility. JPEG/JPG, PNG, WebP, GIF, BMP, HEIC, and HEIF inputs are accepted after content validation; each file can be up to 30 MB.
Poll: GET /api/ai-tasks?taskId=...
Batch photo
POST /api/ai-tasks/batch-face-swap
Use mode=singleToMulti with exactly one repeated sourceImages field and one or more targetImages fields. Use mode=multiToSingle with one or more sourceImages fields and exactly one targetImages field.
The request can contain no more than 20 images, 30 MB each and 95 MB combined. Accepted formats are JPEG, PNG, WebP, AVIF, HEIC, and HEIF.
Poll: GET /api/ai-tasks/batch-face-swap?taskId=...
Mapped group photo
POST /api/ai-tasks/multi-face-swap
Send the group photo as sourceImage. Add replacement identities in contiguous fields from targetFace0 through targetFace9, with one matching faceBox0 through faceBox9 JSON object for every replacement. Each mapping contains x, y, width, and height; include the optional 0-based global faceIndex when leaving other detected faces unchanged.
Either map every replacement face or omit every face box. JPEG, PNG, and WebP are accepted, with a 30 MB per-file and 95 MB total limit.
Poll: GET /api/ai-tasks/multi-face-swap?taskId=...
Video
POST /api/ai-tasks/video
Send sourceImage and targetVideo. Output is fixed to the highest supported 1080p tier; a lower client-supplied quality value is ignored. The reference image can be up to 30 MB; MP4, MOV, and WebM targets can be up to 95 MB and 600 seconds, and both files must be 95 MB or smaller combined.
Measured duration is rounded up. Face-only processing with scene preservation costs 1 credit per second with a 5-credit minimum at 1080p. The current endpoint does not accept broader character or scene replacement.
Poll: GET /api/ai-tasks/video?taskId=...
GIF / short clip
POST /api/ai-tasks/gif
Send sourceImage and targetGif. The target can be GIF, MP4, or WebM, up to 95 MB and 30 seconds. The reference image can be up to 30 MB, and both files must be 95 MB or smaller combined. Duration is rounded up and billed at 1 credit per second with a 5-credit minimum.
Poll: GET /api/ai-tasks/gif?taskId=...
Task lifecycle
Keep the taskId and stop at a terminal state
Use the same API key to poll a task. A taskId can only be read by its owning account. Poll at a measured interval rather than in a tight loop. The response includes the task type, current status, credit cost, timestamps, parameters, and a result object when available.
Errors and limits
Handle status codes before retrying
| Status | Meaning | Client action |
|---|---|---|
| 400 | Invalid field, media, mapping, size, duration, or taskId. | Correct the request; do not retry unchanged. |
| 401 | Missing or invalid Bearer API key. | Replace or recreate the key. |
| 402 | Insufficient credits, no completed purchase for API access, or the browser trial network/account allowance is exhausted. | Complete a credit purchase for API use or add credits, then submit a new task. |
| 403 | Account email is not verified. | Complete email verification. |
| 404 | The taskId does not belong to this account. | Check the route, key, and taskId. |
| 429 | Key limit exceeded or another generation is active. | Honor Retry-After when supplied and use backoff. |
| 500 | The request could not be accepted or read. | Retry later with bounded exponential backoff. |
Generation requests are limited to 6 per API key per minute, with a broader 20-request-per-minute API default. When the per-key limit is exhausted, the response supplies Retry-After, X-RateLimit-Limit, and X-RateLimit-Remaining. Separate account-level protection allows one active generation at a time.
Billing and delivered output
API access is paid-only; credits settle with each task
Creating or using an API key requires a verified email and at least one PAID or COMPLETED credit order. Reward and trial credits are web-only and cannot be automated through API keys. Existing keys on accounts without a qualifying order are blocked until the account pays.
Each account can hold no more than three API keys. Generation credits are reserved with the task and failed processing tasks are refunded automatically. Review current credit pricing before funding an integration.
Trial image exports show DeepSwapAI.com and the account's 100% complete email address; it is never masked, shortened, hashed, or omitted. This boundary applies only to image exports, and a completed purchase makes future image exports watermark-free.
API questions
Current integration boundaries
Does the API support webhooks?
No. Submit the task, retain its taskId, and poll GET on the same workflow endpoint until a terminal status.
Is there an official SDK?
No official language SDK is currently published. Use any server-side HTTP client that supports Bearer headers, multipart form data, and JSON.
How much does one DeepSwapAI API generation cost?
A photo task uses 3 credits, currently equivalent to about $0.096-$0.150 depending on the full credit pack. Batch and group-photo requests scale by output or selected face; video and GIF requests use the duration formulas above. Polling GET requests do not create another generation charge. Failed processing tasks are refunded.
Can published face swap API prices be compared directly?
No. Provider units differ by call, frame, second, resolution, face count, enhancement, subscription, or credit pack. Compare one identical representative task and retain any official-source conflicts.
Does the contract landscape identify the best face swap API?
No. It records public contract evidence only. No generation request was run and no provider was ranked for output quality, latency, reliability, safety, or value.
Can trial or reward credits be used through the API?
No. API keys are available only after email verification and a PAID or COMPLETED credit order. Trial and reward credits remain web-only.