> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modelslab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Train a Lora Model with Custom Images

> Train a Lora model  on normal lora and sdxl with any object or person with your own images.

## Request

Make a `POST` request to below endpoint and pass the required parameters as a request body.

```curl curl theme={null}
--request POST 'https://modelslab.com/api/v3/lora_fine_tune' \
```

<Note>
  You can train a model on normal lora models and sdxl and get its style for this endpoint, also each training cost \$1. Fund your you wallet to get started
</Note>

### Training Types

The table below lists all the possible values for the `training_type` parameter.

| Value      | Description                                                                                                        |
| :--------- | :----------------------------------------------------------------------------------------------------------------- |
| **men**    | Train on faces of men.                                                                                             |
| **female** | Train on faces of females.                                                                                         |
| **couple** | Train on couples of male and female; in images array pass images of couples, instead of images of a single person. |
| **null**   | Train on object or anything.                                                                                       |

### Training Status Values

The table below describes all possible training statuses.

| Status                      | Description                        |
| :-------------------------- | :--------------------------------- |
| deploying\_gpu              | Deploying GPU                      |
| training\_started           | Training started                   |
| training\_success           | Training completed successfully    |
| trained\_model\_compressing | Compressing the trained model      |
| trained\_model\_uploading   | Uploading the trained model        |
| trained\_model\_uploaded    | Trained model uploaded             |
| deploying\_model            | Deploying the trained model        |
| model\_ready                | The trained model is ready for use |

## Body

```json json theme={null}
{    
    "key":"",    
    "instance_prompt": "photo of ambika0 man",    
    "class_prompt": "photo of a man",    
    "base_model_type": "sdxl",    
    "negative_prompt":" lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",    
    "images": [    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/2.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/3.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/4.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/5.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/6.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/7.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/8.png",    
        "https://raw.githubusercontent.com/pnavitha/sampleImages/master/9.png"  
    ],    
    "seed": "0",    
    "training_type": "men",    
    "max_train_steps": "18",    
    "lora_type":"lora",    
    "webhook": null
}
```

### Webhook

This is an example webhook post call in JSON format.

```json json theme={null}
{ 
    "status": "success", 
    "training_status": "deploying_gpu", 
    "logs": "it will take upto 25 minutes", 
    "model_id": "F5jvdzGnYi"
}
```

### Request[​](#request-1 "Direct link to Request")

* JS
* PHP
* NODE
* PYTHON
* JAVA

```
var myHeaders = new Headers();myHeaders.append("Content-Type", "application/json");var raw = JSON.stringify({    "key":"",    "instance_prompt": "photo of ambika0 man",    "class_prompt": "photo of a man",    "base_model_type": "sdxl",    "negative_prompt":" lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",    "images": [    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/2.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/3.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/4.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/5.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/6.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/7.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/8.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/9.png"  ],    "seed": "0",    "training_type": "men",    "max_train_steps": "18",    "lora_type":"lora",    "webhook": null});var requestOptions = {  method: 'POST',  headers: myHeaders,  body: raw,  redirect: 'follow'};fetch("https://modelslab.com/api/v3/lora_fine_tune", requestOptions)  .then(response => response.text())  .then(result => console.log(result))  .catch(error => console.log('error', error));
```

```
<?php$payload = [  "key" => "",   "instance_prompt" => "photo of ambika0 man",   "class_prompt" => "photo of person",   "base_model_type" => "sdxl",  "negative_prompt" => " lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",  "images" => [    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/2.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/3.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/4.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/5.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/6.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/7.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/8.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/9.png"  ],   "seed" => "0",   "training_type" => "men",   "lora_type":"lora",  "max_train_steps" => "18",   "webhook" => "" ];$curl = curl_init();curl_setopt_array($curl, array(  CURLOPT_URL => 'https://modelslab.com/api/v3/lora_fine_tune',  CURLOPT_RETURNTRANSFER => true,  CURLOPT_ENCODING => '',  CURLOPT_MAXREDIRS => 10,  CURLOPT_TIMEOUT => 0,  CURLOPT_FOLLOWLOCATION => true,  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,  CURLOPT_CUSTOMREQUEST => 'POST',  CURLOPT_POSTFIELDS => json_encode($payload),  CURLOPT_HTTPHEADER => array(    'Content-Type: application/json'  ),));$response = curl_exec($curl);curl_close($curl);echo $response;
```

```
var request = require('request');var options = {  'method': 'POST',  'url': 'https://modelslab.com/api/v3/lora_fine_tune',  'headers': {    'Content-Type': 'application/json'  },  body: JSON.stringify({    "key":"",    "instance_prompt": "photo of ambika0 man",    "class_prompt": "photo of a man",    "base_model_type": "sdxl",    "negative_prompt":" lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",    "images": [    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/2.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/3.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/4.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/5.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/6.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/7.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/8.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/9.png"  ],    "seed": "0",    "training_type": "men",    "max_train_steps": "18",    "lora_type":"lora",    "webhook": null  })};request(options, function (error, response) {  if (error) throw new Error(error);  console.log(response.body);});
```

```
import requestsimport jsonurl = "https://modelslab.com/api/v3/lora_fine_tune"payload = json.dumps({    "key":"",    "instance_prompt": "photo of ambika0 man",    "class_prompt": "photo of a man",    "base_model_type": "sdxl",    "negative_prompt":" lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",    "images": [    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/2.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/3.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/4.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/5.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/6.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/7.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/8.png",    "https://raw.githubusercontent.com/pnavitha/sampleImages/master/9.png"    ],    "seed": "0",    "training_type": "men",    "max_train_steps": "18",    "lora_type":"lora",    "webhook": "",})headers = {  'Content-Type': 'application/json'}response = requests.request("POST", url, headers=headers, data=payload)print(response.text)
```

```
OkHttpClient client = new OkHttpClient().newBuilder()  .build();MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{\n    \"key\":\"\",\n    \"instance_prompt\": \"photo of ambika0 man\",\n    \"class_prompt\": \"photo of a man\",\n    \"base_model_type\": \"normal\",\n    \"negative_prompt\":\" lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry\",\n    \"images\": [\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/2.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/3.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/4.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/5.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/6.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/7.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/8.png\",\n    \"https://raw.githubusercontent.com/pnavitha/sampleImages/master/9.png\"\n  ],\n    \"seed\": \"0\",\n    \"training_type\": \"men\",\n    \"max_train_steps\": \"18\",\n    \"lora_type\":\"lora\",\n    \"webhook\": null\n}");Request request = new Request.Builder()  .url("https://modelslab.com/api/v3/lora_fine_tune")  .method("POST", body)  .addHeader("Content-Type", "application/json")  .build();Response response = client.newCall(request).execute();
```

### Response[​](#response "Direct link to Response")

```
{  "status": "success",  "messege": "deploying_gpu",  "data": "it will take upto 30 minutes.",  "training_id": "F5jvdzGnYi"}
```


## OpenAPI

````yaml POST /lora_fine_tune
openapi: 3.0.3
info:
  title: ModelsLab Training API
  description: >-
    API endpoints for training LoRA models, managing training processes, and
    handling training-related operations.
  version: 3.0.0
  contact:
    name: ModelsLab Support
    url: https://modelslab.com
servers:
  - url: https://modelslab.com/api/v3
    description: V3 API Endpoints
security: []
tags:
  - name: Training
    description: Operations for training LoRA models and managing training processes
  - name: Model Management
    description: Operations for managing trained models
  - name: Utilities
    description: Utility operations for image processing and preparation
paths:
  /lora_fine_tune:
    post:
      tags:
        - Training
      summary: Train a Lora Model with Custom Images
      description: >-
        Using this endpoint you can train a Lora model with your own images. You
        can train a model on any object or person.
      operationId: trainLoraModel
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoraTrainingRequest'
            example:
              key: your_api_key
              instance_prompt: photo of ambika0 man
              class_prompt: photo of a man
              base_model_type: sdxl
              negative_prompt: >-
                lowres, bad anatomy, bad hands, text, error, missing fingers,
                extra digit, fewer digits, cropped, worst quality, low quality,
                normal quality, jpeg artifacts, signature, watermark, username,
                blurry
              images:
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/2.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/3.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/4.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/5.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/6.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/7.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/8.png
                - >-
                  https://raw.githubusercontent.com/pnavitha/sampleImages/master/9.png
              seed: '0'
              training_type: men
              max_train_steps: '18'
              lora_type: lora
              webhook: null
      responses:
        '200':
          description: Training initiated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrainingResponse'
              example:
                status: success
                messege: deploying_gpu
                data: it will take upto 30 minutes.
                training_id: F5jvdzGnYi
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    LoraTrainingRequest:
      type: object
      required:
        - key
        - instance_prompt
        - class_prompt
        - images
        - training_type
        - max_train_steps
      properties:
        key:
          type: string
          description: Your API Key used for request authorization
        instance_prompt:
          type: string
          description: Text prompt with how you want to call your trained person/object
          example: photo of ambika0 man
        wandb_key:
          type: string
          description: Key to the wandb platform to monitor your training process
        class_prompt:
          type: string
          description: Classification of the trained person/object
          example: photo of a man
        base_model_type:
          type: string
          enum:
            - normal
            - sdxl
          description: The type of LoRA base model you want to train on
          default: sdxl
        negative_prompt:
          type: string
          description: Items you don't want in the image
          default: ' lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry'
          example: lowres, bad anatomy, bad hands, text, error
        images:
          type: array
          items:
            type: string
            format: uri
          description: >-
            Accessible direct links to images, cropped to 512x512 pixels. A good
            number is about 7-8 images
          minItems: 1
        training_type:
          type: string
          enum:
            - men
            - women
            - couple
            - 'null'
          default: men
          description: The type of the object you are training on
        lora_type:
          type: string
          enum:
            - lora
            - lycoris
          description: Type of LoRA model
          default: lora
        max_train_steps:
          type: string
          description: >-
            Set at 2 times the number of images (Ni*2); minimum value is 10 and
            maximum value is 50
          default: '18'
          example: '18'
        seed:
          type: string
          description: Random seed for reproducible results
          default: '0'
        webhook:
          type: string
          format: uri
          nullable: true
          description: Set a URL to receive a POST call when training is complete
    TrainingResponse:
      type: object
      properties:
        status:
          type: string
          example: success
        messege:
          type: string
          description: Current training status
          enum:
            - deploying_gpu
            - training_started
            - training_success
            - trained_model_compressing
            - trained_model_uploading
            - trained_model_uploaded
            - deploying_model
            - model_ready
        data:
          type: string
          description: Additional information about the training process
        training_id:
          type: string
          description: Unique identifier for the training job
    Error:
      type: object
      properties:
        status:
          type: string
          example: error
        messege:
          type: string
          description: Error description
        code:
          type: integer
          description: Error code
  responses:
    BadRequest:
      description: Bad request - Invalid parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized - Invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'

````