# FaceSwap Image and Video Face Swap API

### ⚠️ Please use this API instead! <a href="#please-use-this-api-instead" id="please-use-this-api-instead"></a>

Capix has decided to shut down this on 21st May 2025. To help our customers, we have released a compatible FaceSwap API built by engineers at API.market. Please reach out to support for any questions or help.\
\
[**Please instead use the API at: MagicAPI FaceSwap-Capix API (https://api.market/store/magicapi/faceswap-capix)**](https://api.market/store/magicapi/faceswap-capix)

#### [Try FaceSwap Image & Video API on API.market](/api-product-docs/magicapi/faceswap-api-instantaneous-replaces-face-with-one-another.md)

The FaceSwap Image & Video API offers a straightforward solution for replacing faces in images and videos. With over 500% cost savings compared to other services, it is the most affordable and reliable option available. This face swap AI API enables seamless face swapping using simple HTTP POST requests, making it ideal for developers looking to integrate face-swapping functionality into their applications.

![image](https://blog.api.market/wp-content/uploads/2024/07/Faceswap_api_example.png)

### Key Features

* **High-quality face swapping technology:** Our API utilizes state-of-the-art algorithms to ensure seamless and realistic face swaps in both images and videos.
* **Easy integration:** Comprehensive documentation and straightforward implementation make integrating our API into your project quick and hassle-free.
* **Customization options:** Tailor the faceswap experience to suit your needs with customizable parameters for face detection, alignment, and blending.
* **Scalability and reliability:** Built to handle high volumes of requests with minimal latency, ensuring a smooth and reliable user experience.

### Benefits

* Create hilarious memes, captivating social media content, and personalized experiences for your users.
* Add fun filters to your mobile app, create entertaining videos for your social media platforms, or enhance your marketing campaigns with interactive experiences.

#### Description

The FaceSwap Image & Video API provides developers with the ability to perform face swaps in both images and videos with minimal effort. By leveraging the power of HTTP POST requests, this top face-swap API allows you to specify target and swap URLs to perform the face-swapping operation. The service is designed to be highly reliable and affordable, ensuring that developers can integrate face-swapping features without worrying about excessive costs.

**Key Features:**

* **Image Face Swap**: Replace faces in images using a simple POST request with the best face swap API.
* **Video Face Swap**: Perform face swaps in videos seamlessly with our video face swap API.
* **Cost-Effective**: Over 500% cheaper than other face-swapping APIs.
* **Easy Integration**: Simple HTTP POST requests for quick and easy integration.
* **Reliable Service**: Consistent and dependable performance.

![image](https://blog.api.market/wp-content/uploads/2024/07/Faceswap_example_api.market.png)

#### How to Use

**Image Face Swap:**

1. **Endpoint**: `https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/image`
2. **Method**: POST
3. **Headers**:
   * `accept: application/json`
   * `x-api-market-key: YOUR_API_KEY`
   * `Content-Type: application/x-www-form-urlencoded`
4. **Data**:
   * `target_url`: URL of the image in which the face needs to be swapped.
   * `swap_url`: URL of the image containing the face to be swapped in.

**Example Request:**

```sh
curl -X 'POST' \
  'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/image' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: YOUR_API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'target_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg&swap_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
```

**Video Face Swap:**

1. **Endpoint**: `https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/video`
2. **Method**: POST
3. **Headers**:
   * `accept: application/json`
   * `x-api-market-key: YOUR_API_KEY`
   * `Content-Type: application/x-www-form-urlencoded`
4. **Data**:
   * `target_url`: URL of the video in which the face needs to be swapped.
   * `swap_url`: URL of the image containing the face to be swapped in.

**Example Request:**

```sh
curl -X 'POST' \
  'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/video' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: YOUR_API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'target_url=https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4&swap_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
```

**Retrieve Face Swap Result:**

1. **Endpoint**: `https://prod.api.market/api/v1/capix/faceswap/result/`
2. **Method**: POST
3. **Headers**:
   * `accept: application/json`
   * `x-api-market-key: YOUR_API_KEY`
   * `Content-Type: application/x-www-form-urlencoded`
4. **Data**:
   * `request_id`: The unique request ID received after initiating the face swap.

**Example Request:**

```sh
curl -X 'POST' \
  'https://prod.api.market/api/v1/capix/faceswap/result/' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: YOUR_API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'request_id=16bbe697-1323-4ead-9104-30a65ba52149'
```

![image](https://telegra.ph/file/8df15175c95a5b6793840.jpg)

**Note:** The Video Faceswap API is limited to a maximum duration of 4 seconds, even on premium or other plans. Additionally, this API cannot be used for any NSFW content or images, as that violates our policy.

By following these steps, developers can easily integrate face-swapping functionality into their applications using the FaceSwap API. Whether you need an image face swap API, video face swap API, or even a free face swap API for trial purposes, this service provides the most reliable and cost-effective solution on the market.

![image](https://telegra.ph/file/8df15175c95a5b6793840.jpg)

### Image Process

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X 'POST' \
  'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/image' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'target_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg&swap_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'target_url': 'https://storage.ws.pho.to/s2/7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg',
    'swap_url': 'https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg',
}

response = requests.post('https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/image', headers=headers, data=data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/image');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-api-market-key: API_KEY',
    'Content-Type: application/x-www-form-urlencoded',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'target_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg&swap_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg');

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.post(
  'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/image',
  new URLSearchParams({
    'target_url': 'https://storage.ws.pho.to/s2/7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg',
    'swap_url': 'https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
  }),
  {
    headers: {
      'accept': 'application/json',
      'x-api-market-key': 'API_KEY'
    }
  }
);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch('https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/image', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY'
  },
  body: new URLSearchParams({
    'target_url': 'https://storage.ws.pho.to/s2/7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg',
    'swap_url': 'https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
  })
});
```

{% endtab %}
{% endtabs %}

### Video Process

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X 'POST' \
  'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/video' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'target_url=https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4&swap_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'target_url': 'https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4',
    'swap_url': 'https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg',
}

response = requests.post('https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/video', headers=headers, data=data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/video');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-api-market-key: API_KEY',
    'Content-Type: application/x-www-form-urlencoded',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'target_url=https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4&swap_url=https%3A%2F%2Fstorage.ws.pho.to%2Fs2%2F818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg');

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.post(
  'https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/video',
  new URLSearchParams({
    'target_url': 'https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4',
    'swap_url': 'https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
  }),
  {
    headers: {
      'accept': 'application/json',
      'x-api-market-key': 'API_KEY'
    }
  }
);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch('https://prod.api.market/api/v1/capix/faceswap/faceswap/v1/video', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY'
  },
  body: new URLSearchParams({
    'target_url': 'https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4',
    'swap_url': 'https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg'
  })
});
```

{% endtab %}
{% endtabs %}

### Get Result

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X 'POST' \
  'https://prod.api.market/api/v1/capix/faceswap/result/' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'request_id=16bbe697-1323-4ead-9104-30a65ba52149'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'request_id': 'REQUEST_ID',
}

response = requests.post('https://prod.api.market/api/v1/capix/faceswap/result/', headers=headers, data=data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://prod.api.market/api/v1/capix/faceswap/result/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-api-market-key: API_KEY',
    'Content-Type: application/x-www-form-urlencoded',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'request_id=REQUEST_ID');

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.post(
  'https://prod.api.market/api/v1/capix/faceswap/result/',
  new URLSearchParams({
    'request_id': 'REQUEST_ID'
  }),
  {
    headers: {
      'accept': 'application/json',
      'x-api-market-key': 'API_KEY'
    }
  }
);
```

{% endtab %}

{% tab title="Javscript" %}

```javascript
fetch('https://prod.api.market/api/v1/capix/faceswap/result/', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY'
  },
  body: new URLSearchParams({
    'request_id': 'REQUEST_ID'
  })
});
```

{% endtab %}
{% endtabs %}

### ⚠️ Please use this API instead! <a href="#please-use-this-api-instead" id="please-use-this-api-instead"></a>

Capix has decided to shut down this on 21st May 2025. To help our customers, we have released a compatible FaceSwap API built by engineers at API.market. Please reach out to support for any questions or help.\
\
[**Please instead use the API at: MagicAPI FaceSwap-Capix API (https://api.market/store/magicapi/faceswap-capix)**](https://api.market/store/magicapi/faceswap-capix)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.market/api-product-docs/capix-ai/faceswap-image-and-video-face-swap-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
