# Krea 2 Trainer

> Train a custom LoRA on your own images to teach Krea 2 a new subject, character, or style. Provide a set of training images (and an optional trigger word), and the trainer outputs LoRA weights you can use for inference with the Krea 2 LoRA endpoint.


## Overview

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



## Pricing

Your request will cost **$0.003 per step** (minimum of 100 steps is charged). For **$3.00** you can fine-tune a LoRA for **1000 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:


- **`images_data_url`** (`string`, _required_):
  URL to a .zip archive of training images (PNG/JPG/JPEG/WebP). Each image may carry a same-stem caption: an image named ROOT.EXT (e.g. 001.jpg) pairs with a caption file named ROOT.txt (e.g. 001.txt). Images with no caption file fall back to `trigger_phrase`, so each image must have either a caption file or a non-empty `trigger_phrase` — otherwise the request is rejected (422).

- **`trigger_phrase`** (`string`, _optional_):
  Instance phrase used as the caption for any image that ships no .txt caption file (DreamBooth-style); also seeds the default validation prompts. Required when some images have no caption file and auto_captioning is Off. Default value: `""`
  - Default: `""`

- **`auto_captioning`** (`AutoCaptioningEnum`, _optional_):
  Optional automatic captioning mode. Off preserves the existing behavior: every image must include a same-stem .txt caption or fall back to trigger_phrase. Object/Character, Style, and Custom use dataset-captioner to generate captions with google/gemma-4-31B-it; trigger_phrase is included in the captioning prompt and normalized in the final sidecars using the selected LoRA captioning convention. Cost of captioning will be passed through directly. Default value: `"Off"`
  - Default: `"Off"`
  - Options: `"Off"`, `"Object/Character"`, `"Style"`, `"Custom"`

- **`steps`** (`integer`, _optional_):
  Number of LoRA training steps. Default value: `100`
  - Default: `100`
  - Range: `50` to `10000`

- **`learning_rate`** (`float`, _optional_):
  Learning rate for the LoRA B factor (and for A when lora_a_lr_multiplier=1). Krea recommends 3e-4–7e-4 (constant schedule). For muon this is the match_rms_adamw-scaled (AdamW-equivalent) rate. Default value: `0.0005`
  - Default: `0.0005`
  - Range: `0.000001` to `0.01`

- **`resolution`** (`ResolutionEnum`, _optional_):
  Training resolution (images are cover-resized + center-cropped to a square). 768 trains ~1.7x faster at lower VRAM with near-identical style quality; 1024 maximizes fine detail. Default value: `"768"`
  - Default: `768`
  - Options: `768`, `1024`

- **`debug_dataset`** (`boolean`, _optional_):
  When enabled, returns a downloadable archive of the exact dataset used for training after caption backfill or auto-captioning.
  - Default: `false`



**Required Parameters Example**:

```json
{
  "images_data_url": ""
}
```

**Full Example**:

```json
{
  "images_data_url": "",
  "auto_captioning": "Off",
  "steps": 100,
  "learning_rate": 0.0005,
  "resolution": 768
}
```


### Output Schema

The API returns the following output format:

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

- **`config_file`** (`File`, _required_):
  URL to the training/LoRA configuration JSON.

- **`prompt_enhancement_system_prompt`** (`string`, _optional_):
  System prompt for writing or enhancing inference prompts so they match the captioning convention used during auto-captioned training. Returned when auto_captioning is enabled.

- **`debug_dataset`** (`File`, _optional_):
  Downloadable archive of the prepared training data, including auto-generated captions, when debug_dataset is enabled.



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

### fal.ai Platform

- [Platform Documentation](https://fal.ai/docs/documentation)
- [Python Client](https://fal.ai/docs/api-reference/client-libraries/python)
- [JavaScript Client](https://fal.ai/docs/api-reference/client-libraries/javascript)

### Other agent-readable surfaces

This file covers one model. To find anything else:

- [Platform overview](https://fal.ai/llms.txt): Entry points and representative endpoint IDs
- [Documentation index](https://fal.ai/docs/llms.txt): Every documentation page
- [Full documentation text](https://fal.ai/docs/llms-full.txt): The whole documentation inlined
- Any other model: `https://fal.ai/models/<endpoint-id>/llms.txt`
