| --- |
| pipeline_tag: video-to-video |
| --- |
| # Face Swap Video |
| ### Simple HTTP endpoint to generate a face-swapped video. |
|
|
| [Website](https://www.face-swap.co?utm_source=faceswapmodel&utm_medium=website) | [Docs](https://www.face-swap.co/api?utm_source=faceswapmodel&utm_medium=docs) | [API Key](https://www.face-swap.co/api?utm_source=faceswapmodel&utm_medium=apikey) |
|
|
| The Face Swap API lets you generate AI face swap videos with a single HTTP request. Send a source face image, a target video URL, and the desired duration, and our service returns a deepfake-style video face swap URL. |
|
|
| [No code face swap video generations](https://www.face-swap.co?utm_source=faceswapmodel&utm_medium=nocodefaceswap) |
|
|
| [](https://huggingface.co/spaces/tonyassi/video-face-swap) |
|
|
|
|
| <div class="banner-pos" style="width:400px;height:400px;position:relative;overflow:hidden;"> |
| <video |
| class="banner-video" |
| id="banner-video" |
| preload="metadata" |
| poster="https://huggingface.co/spaces/ai-media/storage/resolve/main/banner-poster1.png" |
| autoplay muted loop playsinline |
| style="width:100%;height:100%;object-fit:cover;display:block;" |
| > |
| <source src="https://huggingface.co/spaces/tonyassi/storage/resolve/main/banner1.mp4" type="video/mp4"> |
| Your browser does not support the video tag. |
| </video> |
| |
| <button id="mute-btn" class="mute-btn" type="button" aria-label="Unmute" |
| style="position:absolute;right:12px;bottom:12px;z-index:2;"> |
| π |
| </button> |
| </div> |
| |
| ```python |
| import requests |
| |
| url = "https://www.face-swap.co/api/generate" |
| payload = { |
| "key": "YOUR_API_KEY", |
| "input_image_url": "https://tinyurl.com/elonmusk-faceswap", |
| "input_video_url": "https://tinyurl.com/ironman-faceswap", |
| "duration": 120, # required: 4 | 60 | 120 | 180 (use 4 for trial credits) |
| "gender": "all", # optional: all | female | male (default: all) |
| } |
| |
| r = requests.post(url, json=payload, timeout=60) |
| r.raise_for_status() |
| print(r.json()) |
| ``` |
|
|
| [Get an API Key here](https://www.face-swap.co/api?utm_source=faceswapmodel&utm_medium=apikey) |
|
|
| <a href="https://colab.research.google.com/drive/1OfLNmgUiAek2wQbX5IOOJ5F4iwOUL8Wd?usp=sharing" |
| target="_blank" rel="noopener noreferrer" |
| style="display:inline-flex;align-items:center;gap:10px;padding:10px 14px;border:1px solid rgba(0,0,0,0.15);border-radius:10px;text-decoration:none;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;color:#111;background:#fff;"> |
| <img src="https://colab.research.google.com/img/colab_favicon_256px.png" |
| alt="Google Colab" |
| style="height:22px;width:auto;display:block;"> |
| <span style="font-weight:600;">Colab Notebook</span> |
| </a> |
|
|
| <a href="https://huggingface.co/spaces/tonyassi/face-swap-video-api" |
| target="_blank" rel="noopener noreferrer" |
| style="display:inline-flex;align-items:center;gap:10px;padding:10px 14px;border:1px solid rgba(0,0,0,0.15);border-radius:10px;text-decoration:none;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;color:#111;background:#fff;"> |
| <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" |
| alt="Hugging Face" |
| style="height:22px;width:auto;display:block;"> |
| <span style="font-weight:600;">API Playground</span> |
| </a> |
|
|
| --- |
|
|
| ## POST /api/generate |
| Create a face-swapped video job. |
|
|
| | Parameter | Type | Required | Description | |
| |---|---|---:|---| |
| | `key` | string | β
| Your API key | |
| | `input_image_url` | string | β
| Public URL to a face image | |
| | `input_video_url` | string | β
| Public URL to a target video | |
| | `duration` | int | β
| Allowed: `4`, `60`, `120`, `180` seconds (use `4` for trial credits) | |
| | `gender` | string | β | `all` \| `female` \| `male` (default: `all`) | |
|
|
|
|
| ```python |
| import requests |
| |
| url = "https://www.face-swap.co/api/generate" |
| payload = { |
| "key": "YOUR_API_KEY", |
| "input_image_url": "https://tinyurl.com/elonmusk-faceswap", |
| "input_video_url": "https://tinyurl.com/ironman-faceswap", |
| "duration": 120, # required: 4|60|120|180 (use 4 for trial credits) |
| "gender": "all", # optional: all|female|male (default: all) |
| } |
| |
| r = requests.post(url, json=payload, timeout=60) |
| r.raise_for_status() |
| print(r.json()) |
| ``` |
|
|
| ## GET /api/status/{job_id} |
| Check the status of a job. |
| |
| ```python |
| import requests |
| |
| job_id = "0c1449fc0e764b5ebdfe24a52bd8f8fa" |
| r = requests.get(f"https://www.face-swap.co/api/status/{job_id}", timeout=30) |
| r.raise_for_status() |
| print(r.json()) |
| ``` |
| |
| ## GET /api/credits/{API_KEY} |
| View remaining credits for your API key. |
|
|
| ```python |
| import requests |
| |
| api_key = "YOUR_API_KEY" |
| r = requests.get(f"https://www.face-swap.co/api/credits/{api_key}", timeout=30) |
| r.raise_for_status() |
| print(r.json()) |
| ``` |
|
|
| ## GET /api/jobs/{API_KEY} |
| List recent jobs for your API key. |
| |
| ```python |
| import requests |
| |
| api_key = "YOUR_API_KEY" |
| r = requests.get(f"https://www.face-swap.co/api/jobs/{api_key}", timeout=30) |
| r.raise_for_status() |
| print(r.json()) |
| |
| ``` |
| |
| [Get an API Key here](https://www.face-swap.co/api?utm_source=faceswapmodel&utm_medium=apikey) |
| |