Photo Face Swap API documentation
Replace one detected face in a target photo with a face from a reference photo. Face detection runs inside the task; an unambiguous single target and reference face continue automatically, while multiple detected faces return NEEDS_INPUT with indexed previews.
Endpoints
| Contract item | Value |
|---|---|
| Capability | face-swap |
| Submit | POST https://vidmage.ai/api/v1/face-swap/submit |
| Query | POST https://vidmage.ai/api/v1/face-swap/query |
| Task identifier | taskId |
| Result field | imageUrl |
Authenticate with Authorization: Bearer YOUR_API_KEY. Save the task identifier and query the same capability. Use a stable Idempotency-Key for submission retries.
Product guide: AI Photo Face Swap API
Parameters and input rules
| Field | Type | Required | Default | Meaning and limits |
|---|---|---|---|---|
targetImageUrl | string | Yes | Not specified | Publicly reachable URL of the target photo. |
referenceFaceImageUrl | string | Yes | Not specified | Publicly reachable URL of the photo containing the replacement face. |
targetFaceIndex | integer | No | Not specified | Optional explicit zero-based target index. Omit to auto-select only when exactly one face is detected. Minimum: 0 |
referenceFaceIndex | integer | No | Not specified | Optional explicit zero-based reference index. Omit to auto-select only when exactly one face is detected. Minimum: 0 |
Example request
{
"targetImageUrl": "https://vidmage.ai/assets/images/samples/blue-eyed-woman-sunlight.webp",
"referenceFaceImageUrl": "https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp"
}# Set VIDMAGE_IDEMPOTENCY_KEY to a unique value for this task; preserve it for transport retries.
curl -X POST "https://vidmage.ai/api/v1/face-swap/submit" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: ${VIDMAGE_IDEMPOTENCY_KEY}" \
-H "Content-Type: application/json" \
-d '{"targetImageUrl":"https://vidmage.ai/assets/images/samples/blue-eyed-woman-sunlight.webp","referenceFaceImageUrl":"https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp"}'
# -> { "success": true, "taskId": "...", "creditsRequired": ..., "creditsConsumed": 0, "usageDeferred": true }Task results and recovery
URL of the completed face-swapped image. Read imageUrl from the completed query response. Preserve taskId while the task is running.
curl -X POST "https://vidmage.ai/api/v1/face-swap/query" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "taskId": "TASK_ID_FROM_SUBMIT" }'
# -> { "success": true, "data": { "status": "...", "imageUrl": "https://..." } }Submission authorizes this task; provider work and billing can advance during queries. Initial creditsConsumed: 0 does not mean the task is free. A timeout is not a confirmed failure. Recover the existing task instead of resubmitting.
For face selection and error recovery, follow Task lifecycle. MCP uses the normalized taskId argument in get_task_result, including capabilities whose REST identifier is requestId.
Credits
| Component / option | Rate | Minimum |
|---|---|---|
| Per request | 1 credits / image | — |
A fixed credit charge applies to this API request.
Use the Playground or the MCP credit estimator for your exact inputs. Credits and billing.
