# Z Image Turbo Trainer V2

> Fast LoRA trainer for Z-Image-Turbo, a super fast text-to-image model of 6B parameters developed by Tongyi-MAI.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/z-image-turbo-trainer-v2`
- **Model ID**: `fal-ai/z-image-turbo-trainer-v2`
- **Category**: training
- **Kind**: training
**Tags**: lora, personalization, trainer



## Pricing

Your request will cost **$0.85** per **1000-step** training run. It scales per step, so a **2000-step** training run will cost **$1.70**.

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:


- **`image_data_url`** (`string`, _required_):
  URL to the input data zip archive.
  
  The zip should contain pairs of images and corresponding captions.
  
  The images should be named: ROOT.EXT. For example: 001.jpg
  
  The corresponding captions should be named: ROOT.txt. For example: 001.txt
  
  If no text file is provided for an image, the default_caption will be used.

- **`steps`** (`integer`, _optional_):
  Number of steps to train for Default value: `2000`
  - Default: `2000`
  - Range: `10` to `40000`

- **`default_caption`** (`string`, _optional_):
  Default caption to use when caption files are missing. If None, missing captions will cause an error.

- **`learning_rate`** (`float`, _optional_):
  Learning rate. Default value: `0.0005`
  - Default: `0.0005`



**Required Parameters Example**:

```json
{
  "image_data_url": ""
}
```

**Full Example**:

```json
{
  "image_data_url": "",
  "steps": 2000,
  "learning_rate": 0.0005
}
```


### Output Schema

The API returns the following output format:

- **`diffusers_lora_file`** (`File`, _required_):
  URL to the trained diffusers lora weights.

- **`config_file`** (`File`, _required_):
  URL to the configuration file for the trained model.



**Example Response**:

```json
{
  "diffusers_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/z-image-turbo-trainer-v2 \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_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/z-image-turbo-trainer-v2",
    arguments={
        "image_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/z-image-turbo-trainer-v2", {
  input: {
    image_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/z-image-turbo-trainer-v2)
- [API Documentation](https://fal.ai/models/fal-ai/z-image-turbo-trainer-v2/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/z-image-turbo-trainer-v2)

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