# 🎭 FaceSwap API: Instantaneous replaces face with one another

> Seamlessly Swap Faces Between Images in Seconds Instantly create captivating face swaps: Our cutting-edge API lets you seamlessly blend two faces.

### About

The FaceSwap API provides a robust and efficient solution for developers looking to integrate face-swapping capabilities into their applications. By simply providing URLs of two images, this API can swap the faces between them, producing a new image that combines elements of both originals.

**Key Features:**

* **Fast and Reliable:** Our API consistently returns results in under 30 seconds, ensuring a smooth and efficient user experience.
* **Cost-Effective:** Designed with efficiency in mind, this API offers competitive pricing, making it accessible for projects of all sizes.
* **High-Quality Outputs:** Utilize advanced algorithms to ensure high-quality face swaps with natural-looking results.
* **Content Filtering:** The API automatically filters out NSFW content, ensuring that it is not processed.

**Content Restrictions:** Please note that the FaceSwap API does not process nude or NSFW (Not Safe For Work) images. If you encounter any errors or if the API incorrectly flags some of your images as NSFW, please contact our support team for assistance. We are committed to providing accurate and efficient service, and we will help resolve your issues promptly.

**Example Use Case:** Imagine swapping the face of Elon Musk onto the image of Shahrukh Khan. Provide the API with URLs for both images, and within seconds, receive a new image where Elon Musk's face is seamlessly integrated onto Shahrukh Khan's body.

**Example Request:**

```bash
curl -X 'POST' \
  'https://api.magicapi.dev/api/v1/magicapi/faceswap/' \
  -H 'accept: application/json' \
  -H 'x-magicapi-key: you-api-key' \
  -H 'Content-Type: application/json' \
  -d '{
  "input": {
    "swap_image": "https://blog.api.market/wp-content/uploads/2024/06/Elon_Musk.png",
    "target_image": "https://blog.api.market/wp-content/uploads/2024/06/Shahrukh_khan.png"
  }
}'
```

**Example Response:**

```json
{
    "output": "https://blog.api.market/wp-content/uploads/2024/06/face_swap_elon_shahrukh.jpeg"
}
```

**Visual Examples:**

Input Images:

* ![Elon Musk](https://blog.api.market/wp-content/uploads/2024/06/Elon_Musk.png)
* ![Shahrukh Khan](https://blog.api.market/wp-content/uploads/2024/06/Shahrukh_khan.png)

Resulting Image:

* ![Result](https://blog.api.market/wp-content/uploads/2024/06/face_swap_elon_shahrukh.jpeg)

**Why Choose FaceSwap API?** Unlike other face-swapping technologies, our API is not only fast but also reliably returns results within a 30-second window, regardless of the server load. This makes it an excellent choice for applications requiring real-time processing and consistent performance. The added security of automatic NSFW content filtering ensures that your application remains appropriate for all users.

Integrate the FaceSwap API into your application today to add a fun and engaging element that impresses your users with both speed and quality!

#### Developer Portal: <https://api.market/store/magicapi/faceswap>

![image](https://telegra.ph/file/d427250819148c80e0875.png)

<figure><img src="/files/eY4Fq5dvqk1WQAIdk1yV" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Ch0PCYjIGcKgSy0E8gRg" alt=""><figcaption></figcaption></figure>

### Curl Requests and Responses

Process the image

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

```bash
curl -X 'POST' \
  'https://api.magicapi.dev/api/v1/magicapi/faceswap/faceswap' \
  -H 'accept: application/json' \
  -H 'x-magicapi-key: API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "swap_image": "SWAP_IMAGE",
  "target_image": "TARGET_IMAGE"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY',
    'Content-Type': 'application/json',
}

json_data = {
    'swap_image': 'SWAP_IMAGE',
    'target_image': 'TARGET_IMAGE',
}

response = requests.post('https://api.magicapi.dev/api/v1/magicapi/faceswap/faceswap', headers=headers, json=json_data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.magicapi.dev/api/v1/magicapi/faceswap/faceswap');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-magicapi-key: API_KEY',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n  \"swap_image\": \"SWAP_IMAGE\",\n  \"target_image\": \"TARGET_IMAGE\"\n}");

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.post(
  'https://api.magicapi.dev/api/v1/magicapi/faceswap/faceswap',
  {
    'swap_image': 'SWAP_IMAGE',
    'target_image': 'TARGET_IMAGE'
  },
  {
    headers: {
      'accept': 'application/json',
      'x-magicapi-key': 'API_KEY',
      'Content-Type': 'application/json'
    }
  }
);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch('https://api.magicapi.dev/api/v1/magicapi/faceswap/faceswap', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    'swap_image': 'SWAP_IMAGE',
    'target_image': 'TARGET_IMAGE'
  })
});
```

{% endtab %}
{% endtabs %}

```json
{
  "output": "https://d3tx3wg2jy0sui.cloudfront.net/ca645194-a94d-4727-b543-a56ab0cfb76c.jpg"
}
```


---

# 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/magicapi/faceswap-api-instantaneous-replaces-face-with-one-another.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.
