# Wan 2.2 Fun Control

> Generate pose or depth controlled video using Alibaba-PAI's Wan 2.2 Fun


## Overview

- **Endpoint**: `https://fal.run/fal-ai/wan-fun-control`
- **Model ID**: `fal-ai/wan-fun-control`
- **Category**: video-to-video
- **Kind**: inference
**Tags**: wan, pose, depth



## Pricing

Your request will cost **$0.10** per **video second**, calculated at 16 frames per second.

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:


- **`prompt`** (`string`, _required_):
  The prompt to generate the video.
  - Examples: "A woman wearing a lavender floral dress spins around in a circle."

- **`negative_prompt`** (`string`, _optional_):
  The negative prompt to generate the video. Default value: `""`
  - Default: `""`

- **`num_inference_steps`** (`integer`, _optional_):
  The number of inference steps. Default value: `27`
  - Default: `27`
  - Range: `4` to `50`

- **`guidance_scale`** (`float`, _optional_):
  The guidance scale. Default value: `6`
  - Default: `6`
  - Range: `1` to `10`

- **`shift`** (`float`, _optional_):
  The shift for the scheduler. Default value: `5`
  - Default: `5`
  - Range: `1` to `10`

- **`seed`** (`integer`, _optional_):
  The seed for the random number generator.

- **`match_input_num_frames`** (`boolean`, _optional_):
  Whether to match the number of frames in the input video. Default value: `true`
  - Default: `true`

- **`num_frames`** (`integer`, _optional_):
  The number of frames to generate. Only used when match_input_num_frames is False. Default value: `81`
  - Default: `81`
  - Range: `49` to `121`

- **`match_input_fps`** (`boolean`, _optional_):
  Whether to match the fps in the input video. Default value: `true`
  - Default: `true`

- **`fps`** (`integer`, _optional_):
  The fps to generate. Only used when match_input_fps is False. Default value: `16`
  - Default: `16`
  - Range: `4` to `60`

- **`control_video_url`** (`string`, _required_):
  The URL of the control video to use as a reference for the video generation.
  - Examples: "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-control-video-input.mp4"

- **`preprocess_video`** (`boolean`, _optional_):
  Whether to preprocess the video. If True, the video will be preprocessed to depth or pose.
  - Default: `false`

- **`preprocess_type`** (`PreprocessTypeEnum`, _optional_):
  The type of preprocess to apply to the video. Only used when preprocess_video is True. Default value: `"depth"`
  - Default: `"depth"`
  - Options: `"depth"`, `"pose"`

- **`reference_image_url`** (`string`, _optional_):
  The URL of the reference image to use as a reference for the video generation.
  - Examples: "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-input-reference-image.webp"



**Required Parameters Example**:

```json
{
  "prompt": "A woman wearing a lavender floral dress spins around in a circle.",
  "control_video_url": "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-control-video-input.mp4"
}
```

**Full Example**:

```json
{
  "prompt": "A woman wearing a lavender floral dress spins around in a circle.",
  "num_inference_steps": 27,
  "guidance_scale": 6,
  "shift": 5,
  "match_input_num_frames": true,
  "num_frames": 81,
  "match_input_fps": true,
  "fps": 16,
  "control_video_url": "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-control-video-input.mp4",
  "preprocess_type": "depth",
  "reference_image_url": "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-input-reference-image.webp"
}
```


### Output Schema

The API returns the following output format:

- **`video`** (`File`, _required_):
  The video generated by the model.
  - Examples: {"url":"https://storage.googleapis.com/falserverless/example_outputs/wan-fun-example-output.mp4"}



**Example Response**:

```json
{
  "video": {
    "url": "https://storage.googleapis.com/falserverless/example_outputs/wan-fun-example-output.mp4"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/wan-fun-control \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "A woman wearing a lavender floral dress spins around in a circle.",
     "control_video_url": "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-control-video-input.mp4"
   }'
```

### 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/wan-fun-control",
    arguments={
        "prompt": "A woman wearing a lavender floral dress spins around in a circle.",
        "control_video_url": "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-control-video-input.mp4"
    },
    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/wan-fun-control", {
  input: {
    prompt: "A woman wearing a lavender floral dress spins around in a circle.",
    control_video_url: "https://storage.googleapis.com/falserverless/example_inputs/wan-fun-control-video-input.mp4"
  },
  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/wan-fun-control)
- [API Documentation](https://fal.ai/models/fal-ai/wan-fun-control/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/wan-fun-control)

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