# Hunyuan Portrait

> HunyuanPortrait is a diffusion-based framework for generating lifelike, temporally consistent portrait animations.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/hunyuan-portrait`
- **Model ID**: `fal-ai/hunyuan-portrait`
- **Category**: image-to-video
- **Kind**: inference
**Tags**: animation, lip sync



## Pricing

Your request will cost **$0.4** for videos up to **5** seconds. For longer videos, you will be charged **$0.08** per second of output video.

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:


- **`video_url`** (`string`, _required_):
  The URL of the driving video.
  - Examples: "https://v3.fal.media/files/panda/2GQH1q-bJOamqCGWMtKvS_what_if.mp4"

- **`image_url`** (`string`, _required_):
  The URL of the source image.
  - Examples: "https://v3.fal.media/files/elephant/GG7iU-4GmzkX3_gIXutRV_image.png"

- **`seed`** (`integer`, _optional_):
  Random seed for generation. If None, a random seed will be used.

- **`use_arcface`** (`boolean`, _optional_):
  Whether to use ArcFace for face recognition. Default value: `true`
  - Default: `true`



**Required Parameters Example**:

```json
{
  "video_url": "https://v3.fal.media/files/panda/2GQH1q-bJOamqCGWMtKvS_what_if.mp4",
  "image_url": "https://v3.fal.media/files/elephant/GG7iU-4GmzkX3_gIXutRV_image.png"
}
```

**Full Example**:

```json
{
  "video_url": "https://v3.fal.media/files/panda/2GQH1q-bJOamqCGWMtKvS_what_if.mp4",
  "image_url": "https://v3.fal.media/files/elephant/GG7iU-4GmzkX3_gIXutRV_image.png",
  "use_arcface": true
}
```


### Output Schema

The API returns the following output format:

- **`video`** (`File`, _required_):
  The generated video with the portrait animation.
  - Examples: {"file_size":5485412,"file_name":"output_with_audio.mp4","url":"https://v3.fal.media/files/tiger/9H3vkuqNoYcKr6OBGj3Mr_3b01c7a4-802c-4697-b8fb-ad86bd0eba41_output_with_audio.mp4","content_type":"video/mp4"}



**Example Response**:

```json
{
  "video": {
    "file_size": 5485412,
    "file_name": "output_with_audio.mp4",
    "url": "https://v3.fal.media/files/tiger/9H3vkuqNoYcKr6OBGj3Mr_3b01c7a4-802c-4697-b8fb-ad86bd0eba41_output_with_audio.mp4",
    "content_type": "video/mp4"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/hunyuan-portrait \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "video_url": "https://v3.fal.media/files/panda/2GQH1q-bJOamqCGWMtKvS_what_if.mp4",
     "image_url": "https://v3.fal.media/files/elephant/GG7iU-4GmzkX3_gIXutRV_image.png"
   }'
```

### 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(
    "fal-ai/hunyuan-portrait",
    arguments={
        "video_url": "https://v3.fal.media/files/panda/2GQH1q-bJOamqCGWMtKvS_what_if.mp4",
        "image_url": "https://v3.fal.media/files/elephant/GG7iU-4GmzkX3_gIXutRV_image.png"
    },
    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("fal-ai/hunyuan-portrait", {
  input: {
    video_url: "https://v3.fal.media/files/panda/2GQH1q-bJOamqCGWMtKvS_what_if.mp4",
    image_url: "https://v3.fal.media/files/elephant/GG7iU-4GmzkX3_gIXutRV_image.png"
  },
  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/fal-ai/hunyuan-portrait)
- [API Documentation](https://fal.ai/models/fal-ai/hunyuan-portrait/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/hunyuan-portrait)

### 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)
