> For the complete documentation index, see [llms.txt](https://docs.nudify.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nudify.me/generations/image-faceswap.md).

# Image Faceswap

Face Swap allows you to replace a face inside a target image using a source face image. The system automatically handles facial alignment, lighting matching, and blending to produce a natural looking result.

The process is asynchronous. After submitting a request, the API returns a jobId. You can then retrieve the final result using either a webhook callback or a job status request.

### Model

```
nudifyme/img/faceswap
```

### Pricing

```
0.02 / image
```

### Create Face Swap Job

Use this [endpoint](/api/generate.md#post-generate) to start a new face swap generation job.

<table><thead><tr><th width="225">Input</th><th>Description</th></tr></thead><tbody><tr><td>input.imageUrl</td><td>The target image where the new face will be applied.</td></tr><tr><td>input.faceUrl</td><td>The source face image that will be extracted and blended into the target image.</td></tr><tr><td>input.advanced</td><td>Optional boolean that enables occlusion aware face swap processing. Helps when the face is partially covered by hands, hair, or objects.</td></tr></tbody></table>

#### Example Request

```javascript
const response = await fetch(
  'https://api.deepixels.co/v1/generate',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': 'YOUR_API_KEY'
    },
    body: JSON.stringify({
      model: 'nudifyme/img/faceswap',
      input: {
        imageUrl: 'https://images.pexels.com/photos/3756941/pexels-photo-3756941.jpeg',
        faceUrl: 'https://images.pexels.com/photos/2661256/pexels-photo-2661256.jpeg',
        advanced: true
      },
      webhook: 'YOUR_WEBHOOK_URL'
    })
  }
);

const data = await response.json();

console.log(data);
```

#### Job Creation Response

```json
{
  "jobId": "cd5167b9-a7cf-47e9-ad88-8fcb4032daf0",
  "status": "created"
}
```

### Getting Final Results

When processing is complete, the final job result can be received in either of the following ways:

* By sending a GET request to the job status [endpoint](/api/generate.md#get-get)
* Automatically via webhook if a webhook URL was provided during job creation

Both methods return the same response payload.

```json
{
  "jobId": "cd5167b9-a7cf-47e9-ad88-8fcb4032daf0",
  "model": "nudifyme/img/faceswap",
  "status": "completed",
  "input": {
    "imageUrl": "https://images.pexels.com/photos/3756941/pexels-photo-3756941.jpeg",
    "faceUrl": "https://images.pexels.com/photos/2661256/pexels-photo-2661256.jpeg",
    "advanced": true
  },
  "webhook": "YOUR_WEBHOOK_URL",
  "output": {
    "imageUrl": [
      "https://s3.media.deepixels.co/cage/files/b/0a8e439a/hR-5vVdbgaApYSuY0Qm9Y_cca64ff5427642eab37b5d3e6d44d961.jpg"
    ]
  },
  "date": 1770926680739
}
```

<table><thead><tr><th width="225">Input</th><th>Description</th></tr></thead><tbody><tr><td>output.imageUrl</td><td>Array of generated image URLs. Even if only one image is generated, it is returned as an array to support multi-output models in the future.</td></tr></tbody></table>
