# Easel AI Advanced Face Swap

> Swap faces of one or two people at once, while preserving user and scene details!


## Overview

- **Endpoint**: `https://fal.run/easel-ai/advanced-face-swap`
- **Model ID**: `easel-ai/advanced-face-swap`
- **Category**: image-to-image
- **Kind**: inference
**Tags**: face swap, utility, editing



## Pricing

- **Price**: $0.05 per generations

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`face_image_0`** (`Image`, _required_):
  User's face image to face swap FROM
  - Examples: "https://images.easelai.com/mirror_fal/faces/male.png", "https://images.easelai.com/mirror_fal/faces/female.png"

- **`gender_0`** (`(Optional)UserGenderEnum`, _required_):
  The gender of the person in the face image.
  - Options: `"male"`, `"female"`, `"non-binary"`

- **`face_image_1`** (`Image`, _optional_):
  (Optional) The Second face image to face swap FROM
  - Examples: "https://images.easelai.com/mirror_fal/faces/female.png", "https://images.easelai.com/mirror_fal/faces/male.png"

- **`gender_1`** (`SecondUserGenderEnum`, _optional_):
  The gender of the person in the second face image.
  - Options: `"male"`, `"female"`, `"non-binary"`

- **`target_image`** (`Image`, _optional_):
  The target image to face swap TO
  - Examples: "https://images.easelai.com/mirror_fal/men_single_player/rip.jpg", "https://images.easelai.com/mirror_fal/men_single_player/saturday.png", "https://images.easelai.com/mirror_fal/multiplayer/bf.jpg", "https://images.easelai.com/mirror_fal/multiplayer/couple.png", "https://images.easelai.com/mirror_fal/multiplayer/forever.png"

- **`workflow_type`** (`WorkflowTypeEnum`, _required_):
  The type of face swap workflow. target_hair = preserve target's hair. user_hair = preserve user's hair.
  - Options: `"user_hair"`, `"target_hair"`

- **`upscale`** (`boolean`, _optional_):
  Apply 2x upscale and boost quality. Upscaling will refine the image and make the subjects brighter. Default value: `true`
  - Default: `true`

- **`detailer`** (`boolean`, _optional_):
  (Beta) Apply detailer to the image. Detailer will improve certain image details, but slightly increase generation time.
  - Default: `false`



**Required Parameters Example**:

```json
{
  "face_image_0": "https://images.easelai.com/mirror_fal/faces/male.png",
  "gender_0": "male",
  "workflow_type": "user_hair"
}
```

**Full Example**:

```json
{
  "face_image_0": "https://images.easelai.com/mirror_fal/faces/male.png",
  "gender_0": "male",
  "face_image_1": "https://images.easelai.com/mirror_fal/faces/female.png",
  "target_image": "https://images.easelai.com/mirror_fal/men_single_player/rip.jpg",
  "workflow_type": "user_hair",
  "upscale": true
}
```


### Output Schema

The API returns the following output format:

- **`image`** (`Image`, _required_):
  The mirrored image.



**Example Response**:

```json
{
  "image": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019,
    "width": 1024,
    "height": 1024
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/easel-ai/advanced-face-swap \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "face_image_0": "https://images.easelai.com/mirror_fal/faces/male.png",
     "gender_0": "male",
     "workflow_type": "user_hair"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "easel-ai/advanced-face-swap",
    arguments={
        "face_image_0": "https://images.easelai.com/mirror_fal/faces/male.png",
        "gender_0": "male",
        "workflow_type": "user_hair"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("easel-ai/advanced-face-swap", {
  input: {
    face_image_0: "https://images.easelai.com/mirror_fal/faces/male.png",
    gender_0: "male",
    workflow_type: "user_hair"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/easel-ai/advanced-face-swap)
- [API Documentation](https://fal.ai/models/easel-ai/advanced-face-swap/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=easel-ai/advanced-face-swap)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
