VidMage

VidMage is an AI video and image creation platform for creators. Turn your ideas and images into videos and fresh visuals.

Open the creator tools
Explore APIs
AI Video APIsAI Image APIsAI Audio APIsAI 3D APIsAI Face Swap APIsAI Effects APIs
Build with VidMage
QuickstartAPI keysVidMage MCPError reference
Your account
Developer consoleAbout VidMagePlans and creditsAPI billingContact support
© 2026 VidMage. All rights reserved.
Privacy PolicyTerms of ServiceReport Abuse
Skip to content
VidMage/Developers
Overview
APIs
All APIsAI Video APIsAI Image APIsAI Audio APIsAI 3D APIsAI Face Swap APIsAI Effects APIs
DocumentationVidMage MCPOpen console
Developers/AI Head Swap API for Photos and Videos

AI Head Swap API for Photos and Videos

Integrate head replacement into photo and video editing workflows. Send a target asset with one to four reference images, and use an optional prompt to describe the requested change.

Get API keyView API docs
Abstract illustration for AI Head Swap API for Photos and Videos
PlaygroundAPIPricingGuideFAQs

AI Head Swap API Playground

Use your existing API key and subscription. Submitting a generation uses credits; uploading and preparing a request does not start a generation.

API access is available to subscribers only. Your subscription credits are shared across the website and the API.

View plans

Parameter

4 parameters

Publicly reachable URL of the target photo.

One to 4 publicly reachable head-reference image URLs, ordered to match the requested people.

minItems 1maxItems 4

Optional targeting instructions that identify which person or people to replace and map them to Reference 1 through Reference 4.(Optional)

Output aspect ratio.(Optional)

Default: 1:1

Request code

#!/usr/bin/env bash
set -euo pipefail
# Set this once per intended task; preserve it and the body for transport retries.
: "${VIDMAGE_IDEMPOTENCY_KEY:?Set a unique key for this task}"

SUBMIT_RESPONSE="$(curl --fail-with-body --silent --show-error -X POST "https://vidmage.ai/api/v1/head-swap/submit" \
  -H "Authorization: Bearer ${VIDMAGE_API_KEY}" \
  -H "Idempotency-Key: ${VIDMAGE_IDEMPOTENCY_KEY}" \
  -H "Content-Type: application/json" \
  --data-raw '{
  "targetImageUrl": "https://vidmage.ai/assets/images/samples/blue-eyed-woman-sunlight.webp",
  "referenceImageUrls": [
    "https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp"
  ],
  "aspectRatio": "1:1"
}')"
TASK_ID="$(printf '%s' "$SUBMIT_RESPONSE" | jq -er '.["taskId"]')"

while true; do
  QUERY_RESPONSE="$(curl --fail-with-body --silent --show-error -X POST "https://vidmage.ai/api/v1/head-swap/query" \
    -H "Authorization: Bearer ${VIDMAGE_API_KEY}" \
    -H "Content-Type: application/json" \
    --data-raw "{\"taskId\":\"${TASK_ID}\"}")"
  STATUS="$(printf '%s' "$QUERY_RESPONSE" | jq -r '(.status // .data.status // "") | ascii_downcase')"
  case "$STATUS" in
    success|succeeded|completed)
      RESULT="$(printf '%s' "$QUERY_RESPONSE" | jq -r '(.result // .["imageUrl"] // .data["imageUrl"] // empty)')"
      if [ -z "$RESULT" ]; then
        printf '%s' "Result missing; preserve task $TASK_ID and query the same task again. Do not resubmit." >&2
        exit 2
      fi
      printf '%s\n' "$RESULT"
      break
      ;;
    needs_input)
      printf '%s' "Face selection required; preserve task $TASK_ID" >&2
      exit 2
      ;;
    failed|error)
      printf '%s' "$QUERY_RESPONSE" | jq -r '(.message // .error // .data.error // "Task failed")' >&2
      exit 1
      ;;
  esac
  sleep 5
done

Response data

Submit the task to see the API response here.
PlaygroundCapabilities

API documentation

Submit a request, track the task, and retrieve your result.

EndpointPhoto Head Swap ↓
Required inputs
targetImageUrl referenceImageUrls
Output
Image·imageUrl
EndpointVideo Head Swap ↓
Required inputs
targetVideoUrl referenceImageUrls
Output
Video·videoUrl
Request setup & limitsHeaders, input options and media limits

Request headers

Authorization
Bearer YOUR_API_KEY

Keep your API key on your server.

Content-Type
application/json
Idempotency-Key
YOUR_UNIQUE_KEY

Use a new key per task. Reuse it only when retrying the same submission.

Input options & limits

Request controls follow each task's parameter rules; they do not guarantee output properties.

Photo Head Swap

RequiredtargetImageUrl referenceImageUrls
Media limits by mode
  • referenceImageUrlsUp to 4 items.
Request controls
  • customPrompt: see parameter rules
  • aspectRatio: "3:2", "2:3", "16:9", "9:16", "4:3", "3:4", "1:1"

Video Head Swap

RequiredtargetVideoUrl referenceImageUrls
Media limits by mode
  • referenceImageUrlsUp to 4 items.
Request controls
  • customPrompt: see parameter rules

Output dimensions and format are not specified in this reference.

Input retention and output-link lifetime depend on the API contract. Confirm API-specific retention terms before making promises to your users. Upload guide ↗

Photo Head Swap

POST /api/v1/head-swap/submit

Full API documentation ↗

targetImageUrl is required and referenceImageUrls is required.

Required inputs

targetImageUrlstring
Publicly reachable URL of the target photo.
referenceImageUrlsstring[]
One to 4 publicly reachable head-reference image URLs, ordered to match the requested people.

Edit the sample inputs for your own task before submitting.

Photo Head Swap request
# Set VIDMAGE_IDEMPOTENCY_KEY to a unique value for this task; preserve it for transport retries.
curl -X POST "https://vidmage.ai/api/v1/head-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","referenceImageUrls":["https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp"],"aspectRatio":"1:1"}'
# -> { "success": true, "taskId": "...", "creditsConsumed": ... }
Parameters and input rules4 fields
FieldTypeRequiredDefaultMeaning and limits
targetImageUrlstringYesNot specifiedPublicly reachable URL of the target photo. No additional field constraint listed.
referenceImageUrlsstring[]YesNot specifiedOne to 4 publicly reachable head-reference image URLs, ordered to match the requested people. Minimum items: 1 · Maximum items: 4
customPromptstringNoNot specifiedOptional targeting instructions that identify which person or people to replace and map them to Reference 1 through Reference 4. Maximum length: 1000
aspectRatiostringNo"1:1"Output aspect ratio. Values: "3:2", "2:3", "16:9", "9:16", "4:3", "3:4", "1:1" · Default: "1:1"

Retrieve the result

Save taskId from the accepted submission and send it to this endpoint:

POST /api/v1/head-swap/query

Use the same Bearer API key. On completion, read the imageUrl result field.

Task states and recovery ↗
Photo Head Swap query
curl -X POST "https://vidmage.ai/api/v1/head-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://..." } }

Video Head Swap

POST /api/v1/video-head-swap/submit

Full API documentation ↗

targetVideoUrl is required and referenceImageUrls is required.

Required inputs

targetVideoUrlstring
Target-video fileUrl returned by upload_files.
referenceImageUrlsstring[]
One to 4 publicly reachable head-reference image URLs, ordered to match the requested people.

Edit the sample inputs for your own task before submitting.

Video Head Swap request
# 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": ... }
Parameters and input rules3 fields
FieldTypeRequiredDefaultMeaning and limits
targetVideoUrlstringYesNot specifiedTarget-video fileUrl returned by upload_files. No additional field constraint listed.
referenceImageUrlsstring[]YesNot specifiedOne to 4 publicly reachable head-reference image URLs, ordered to match the requested people. Minimum items: 1 · Maximum items: 4
customPromptstringNoNot specifiedOptional targeting instructions that identify which person or people to replace and map them to Reference 1 through Reference 4. Maximum length: 1000

Retrieve the result

Save taskId from the accepted submission and send it to this endpoint:

POST /api/v1/video-head-swap/query

Use the same Bearer API key. On completion, read the videoUrl result field.

Task states and recovery ↗
Video Head Swap query
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://..." } }

Pricing

See what one image, video, or generation costs in credits. Your API and website activity share the same credit balance.

API credit rates and calculated example request costs
API / workflowExample requestPrice (credits)
Photo Head Swapimage API1 image request: 5 credits
How this is calculated
  • Per request: 5 credits / image

A fixed credit charge applies to this API request.

Estimate your own request ↗
5 credits / imageSee calculation details
Video Head Swapvideo API5.875-second video: 90 credits
How this is calculated
  • Video duration: 15 credits / second · 75 credits minimum

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.

Estimate your own request ↗
15 credits / second75 credits minimum
Billed in credits. Shared with the website.Active subscription required. Unit rates and examples follow current API credit rules.Billing details⌄

Examples show the charge for the inputs listed above. Resolution, duration, audio, output count and reference media can change the total. Minimum charges and rounding follow the selected API.

Use the Playground to estimate your request before submitting it. Estimates do not start a generation. Subscription and credit-pack prices are listed on the plans page.

Your task’s recorded usage is the source of truth for the final charge.

View plans ↗Billing guide ↗

About AI Head Swap API

VidMage's AI Head Swap API is an image and video editing interface for changing the appearance of a head using reference images. It accepts a target photo or video, a set of reference images, and an optional text instruction. The output is an edited image or clip. To explore a head replacement in a photo, open VidMage's Head Swap.

AI Head Swap API capabilities

Reference-guided head edits
Provide one to four reference images to guide a head replacement in a target photo or video.
Optional edit instructions
Add a custom prompt to explain the requested appearance when the reference images need more context.
Photo framing choices
Choose a supported aspect ratio for photo edits, including square, portrait, and landscape output framing.

What you can build

Fantasy character redesigns

Try a different head treatment within an existing character scene. Reference images and an optional appearance brief direct the edit, giving concept artists material for comparing silhouettes, hairstyles, and proportions as the design develops.

Costume screen-test previews

The relationship between a costume and a character's head can be hard to judge from separate references. Apply approved head references to a test clip so the production team can examine the proposed look in motion.

Character portrait variants

For a game's character selection screen, artists may need to explore several head designs against one portrait. Make a separate request for each reference set and place the resulting variants together for the art-direction review.

How to use AI Head Swap API

  1. Get an API key

    Create a key in the Developer Console and store it on your server. Use it in the Authorization: Bearer header.

  2. Prepare and submit your inputs

    Set up your inputs in the Playground, then copy the matching API request. Send it from your server with a unique Idempotency-Key.

  3. Track the task

    Save the returned taskId and query the same operation until it completes. Keep that identifier if your app stops waiting.

  4. Retrieve the result

    Read imageUrl or videoUrl from the completed task. Preview the result in your app and save a copy to your own storage for later use.

Input tips
Use a reference array
Send one to four URLs in referenceImageUrls. The optional customPrompt accepts up to 1,000 characters and can clarify the intended change for the edit.
Separate photo and video controls
Only the photo contract exposes aspectRatio. The references are not indexed face mappings, so avoid treating their order as an assignment to different people.

Input requirementsUpload local files

Task fields and results

Keep the task identifier with its original request and Idempotency-Key. Query the same capability until it completes, then read the documented result field.

Task identifier
taskId
Query route
POST /api/v1/head-swap/query
Completed result
imageUrl
Task states and response structure ↗
Errors, retries and limits

Retry transport failures with the same idempotency key only when the original submission may not have reached the server. For a confirmed task, keep querying the original task instead of submitting a duplicate.

Read error recovery guidance ↗

FAQs

Should I choose head swap or face swap?

Choose head swap for a broader head appearance edit. Use face swap for face-specific replacement, or multi-face swap when each person needs an explicit reference mapping.

Are failed or timed-out requests charged?

A client timeout is not a confirmed task failure. Confirmed failures are automatically refunded only when the refund outcome is certain. Unknown charges or refunds remain pending reconciliation.

Failure and refund handling ↗
How long should my app wait for a result?

The checked contract does not establish a fixed completion time. Choose a local wait budget for your app; it is not an API completion deadline.

Polling and wait budgets ↗
What are the rate and concurrency limits?

Request-rate limits control how often you can call the API; concurrency limits control simultaneous work. The documentation ties both to the stable API key but does not publish numeric limits for this operation. Confirm account limits before planning parallel jobs.

Rate-limit recovery ↗
Can I receive results through a webhook?

The checked request contract documents status queries and does not list a webhook or callback field for these routes. Check the current authenticated OpenAPI contract before making a callback part of your integration.

Query task results ↗Check the current contract ↗

Explore more APIs on VidMage

  • AI Video Face Swap API for Clip Workflows↗
  • AI Multi Face Swap API for Photos and Videos↗
  • AI Photo Face Swap API↗
  • AI GIF Face Swap API for Animated Images↗
  • Sora 2 API↗
  • AI Photo Dance API for Reference-Led Animation↗
  • PixVerse API↗
  • Vidu API↗