# Wan-2.1 LoRA Trainer

> Train custom LoRAs for Wan-2.1 I2V 480P


## Overview

- **Endpoint**: `https://fal.run/fal-ai/wan-trainer`
- **Model ID**: `fal-ai/wan-trainer`
- **Category**: training
- **Kind**: training
**Tags**: lora, training



## Pricing

- **Price**: $0.005 per steps

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:


- **`training_data_url`** (`string`, _required_):
  URL to zip archive with images of a consistent style. Try to use at least 10 images and/or videos, although more is better.
  
  In addition to images the archive can contain text files with captions. Each text file should have the same name as the image/video file it corresponds to.

- **`number_of_steps`** (`integer`, _optional_):
  The number of steps to train for. Default value: `400`
  - Default: `400`
  - Range: `100` to `20000`

- **`learning_rate`** (`float`, _optional_):
  The rate at which the model learns. Higher values can lead to faster training, but over-fitting. Default value: `0.0002`
  - Default: `0.0002`
  - Range: `0.000001` to `1`

- **`trigger_phrase`** (`string`, _optional_):
  The phrase that will trigger the model to generate an image. Default value: `""`
  - Default: `""`

- **`auto_scale_input`** (`boolean`, _optional_):
  If true, the input will be automatically scale the video to 81 frames at 16fps.
  - Default: `false`
  - Examples: true



**Required Parameters Example**:

```json
{
  "training_data_url": ""
}
```

**Full Example**:

```json
{
  "training_data_url": "",
  "number_of_steps": 400,
  "learning_rate": 0.0002,
  "auto_scale_input": true
}
```


### Output Schema

The API returns the following output format:

- **`lora_file`** (`File`, _required_):
  URL to the trained LoRA weights.

- **`config_file`** (`File`, _required_):
  Configuration used for setting up the inference endpoints.



**Example Response**:

```json
{
  "lora_file": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  },
  "config_file": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/wan-trainer \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "training_data_url": ""
   }'
```

### 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-trainer",
    arguments={
        "training_data_url": ""
    },
    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-trainer", {
  input: {
    training_data_url: ""
  },
  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-trainer)
- [API Documentation](https://fal.ai/models/fal-ai/wan-trainer/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/wan-trainer)

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