Video Head Swap API documentation
Replace one or more complete heads in a target video while preserving its motion, body, scene, text, head pose, gaze, expression, and mouth movement. Reference images control identity, hairstyle, and skin tone; an optional prompt selects and maps people. Target videos must be 5–15 seconds.
Endpoints
| Contract item | Value |
|---|---|
| Capability | video-head-swap |
| Submit | POST https://vidmage.ai/api/v1/video-head-swap/submit |
| Query | POST https://vidmage.ai/api/v1/video-head-swap/query |
| Task identifier | taskId |
| Result field | videoUrl |
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 Head Swap API for Photos and Videos
Parameters and input rules
| Field | Type | Required | Default | Meaning and limits |
|---|---|---|---|---|
targetVideoUrl | string | Yes | Not specified | Target-video fileUrl returned by upload_files. |
referenceImageUrls | string[] | Yes | Not specified | One to 4 publicly reachable head-reference image URLs, ordered to match the requested people. Minimum items: 1Maximum items: 4 |
customPrompt | string | No | Not specified | Optional targeting instructions that identify which person or people to replace and map them to Reference 1 through Reference 4. Maximum characters: 1000 |
Measured media limits
| Input | Rule |
|---|---|
targetVideoUrl | The server measures this media for billing. Maximum 15 seconds. Do not send duration in the submission body. |
Example request
{
"targetVideoUrl": "https://vidmage.ai/assets/models/hailuo-ai-video-generator/skincare-ad.mp4",
"referenceImageUrls": [
"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/video-head-swap/submit" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: ${VIDMAGE_IDEMPOTENCY_KEY}" \
-H "Content-Type: application/json" \
-d '{"targetVideoUrl":"https://vidmage.ai/assets/models/hailuo-ai-video-generator/skincare-ad.mp4","referenceImageUrls":["https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp"]}'
# -> { "success": true, "taskId": "...", "creditsConsumed": ... }Task results and recovery
URL of the completed head-swapped video. Read videoUrl from the completed query response. Preserve taskId while the task is running.
curl -X POST "https://vidmage.ai/api/v1/video-head-swap/query" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "taskId": "TASK_ID_FROM_SUBMIT" }'
# -> { "success": true, "data": { "status": "...", "videoUrl": "https://..." } }Submission and task queries report the available task and usage information. 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 |
|---|---|---|
| Video duration | 15 credits / second | 75 credits |
The example uses the duration shown above. The server measures uploaded media for billing; this duration is only supplied to the estimate.
Duration is rounded up to whole seconds before applying the minimum duration and per-second rate.
Use the Playground or the MCP credit estimator for your exact inputs. Credits and billing.
