Start Training
curl --request POST \
--url https://modelslab.com/api/v6/trainer/train \
--header 'Content-Type: application/json' \
--data '
{
"key": "<string>",
"trainer_id": "flux_lora_trainer",
"images": [
"<string>"
],
"trigger_word": "<string>",
"hf_username": "<string>",
"hf_token": "<string>",
"training_steps": 1000,
"resolution": 1024
}
'import requests
url = "https://modelslab.com/api/v6/trainer/train"
payload = {
"key": "<string>",
"trainer_id": "flux_lora_trainer",
"images": ["<string>"],
"trigger_word": "<string>",
"hf_username": "<string>",
"hf_token": "<string>",
"training_steps": 1000,
"resolution": 1024
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
key: '<string>',
trainer_id: 'flux_lora_trainer',
images: ['<string>'],
trigger_word: '<string>',
hf_username: '<string>',
hf_token: '<string>',
training_steps: 1000,
resolution: 1024
})
};
fetch('https://modelslab.com/api/v6/trainer/train', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://modelslab.com/api/v6/trainer/train",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'key' => '<string>',
'trainer_id' => 'flux_lora_trainer',
'images' => [
'<string>'
],
'trigger_word' => '<string>',
'hf_username' => '<string>',
'hf_token' => '<string>',
'training_steps' => 1000,
'resolution' => 1024
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://modelslab.com/api/v6/trainer/train"
payload := strings.NewReader("{\n \"key\": \"<string>\",\n \"trainer_id\": \"flux_lora_trainer\",\n \"images\": [\n \"<string>\"\n ],\n \"trigger_word\": \"<string>\",\n \"hf_username\": \"<string>\",\n \"hf_token\": \"<string>\",\n \"training_steps\": 1000,\n \"resolution\": 1024\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://modelslab.com/api/v6/trainer/train")
.header("Content-Type", "application/json")
.body("{\n \"key\": \"<string>\",\n \"trainer_id\": \"flux_lora_trainer\",\n \"images\": [\n \"<string>\"\n ],\n \"trigger_word\": \"<string>\",\n \"hf_username\": \"<string>\",\n \"hf_token\": \"<string>\",\n \"training_steps\": 1000,\n \"resolution\": 1024\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://modelslab.com/api/v6/trainer/train")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"key\": \"<string>\",\n \"trainer_id\": \"flux_lora_trainer\",\n \"images\": [\n \"<string>\"\n ],\n \"trigger_word\": \"<string>\",\n \"hf_username\": \"<string>\",\n \"hf_token\": \"<string>\",\n \"training_steps\": 1000,\n \"resolution\": 1024\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Training request is being processed",
"data": {
"status": "pending",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"meta": {}
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fetch_result": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}Start Training
Queue a LoRA training run on any trainer.
POST
/
train
Start Training
curl --request POST \
--url https://modelslab.com/api/v6/trainer/train \
--header 'Content-Type: application/json' \
--data '
{
"key": "<string>",
"trainer_id": "flux_lora_trainer",
"images": [
"<string>"
],
"trigger_word": "<string>",
"hf_username": "<string>",
"hf_token": "<string>",
"training_steps": 1000,
"resolution": 1024
}
'import requests
url = "https://modelslab.com/api/v6/trainer/train"
payload = {
"key": "<string>",
"trainer_id": "flux_lora_trainer",
"images": ["<string>"],
"trigger_word": "<string>",
"hf_username": "<string>",
"hf_token": "<string>",
"training_steps": 1000,
"resolution": 1024
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
key: '<string>',
trainer_id: 'flux_lora_trainer',
images: ['<string>'],
trigger_word: '<string>',
hf_username: '<string>',
hf_token: '<string>',
training_steps: 1000,
resolution: 1024
})
};
fetch('https://modelslab.com/api/v6/trainer/train', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://modelslab.com/api/v6/trainer/train",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'key' => '<string>',
'trainer_id' => 'flux_lora_trainer',
'images' => [
'<string>'
],
'trigger_word' => '<string>',
'hf_username' => '<string>',
'hf_token' => '<string>',
'training_steps' => 1000,
'resolution' => 1024
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://modelslab.com/api/v6/trainer/train"
payload := strings.NewReader("{\n \"key\": \"<string>\",\n \"trainer_id\": \"flux_lora_trainer\",\n \"images\": [\n \"<string>\"\n ],\n \"trigger_word\": \"<string>\",\n \"hf_username\": \"<string>\",\n \"hf_token\": \"<string>\",\n \"training_steps\": 1000,\n \"resolution\": 1024\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://modelslab.com/api/v6/trainer/train")
.header("Content-Type", "application/json")
.body("{\n \"key\": \"<string>\",\n \"trainer_id\": \"flux_lora_trainer\",\n \"images\": [\n \"<string>\"\n ],\n \"trigger_word\": \"<string>\",\n \"hf_username\": \"<string>\",\n \"hf_token\": \"<string>\",\n \"training_steps\": 1000,\n \"resolution\": 1024\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://modelslab.com/api/v6/trainer/train")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"key\": \"<string>\",\n \"trainer_id\": \"flux_lora_trainer\",\n \"images\": [\n \"<string>\"\n ],\n \"trigger_word\": \"<string>\",\n \"hf_username\": \"<string>\",\n \"hf_token\": \"<string>\",\n \"training_steps\": 1000,\n \"resolution\": 1024\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Training request is being processed",
"data": {
"status": "pending",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"meta": {}
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fetch_result": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}Starts a LoRA training run.
trainer_id picks the trainer, and each trainer takes its own fields. Pick your trainer in the Body tabs below for a ready-to-send request. The parameter list describes every field; switch its body type to your trainer.
Request
Make aPOST request to the endpoint below with the required parameters.
POST https://modelslab.com/api/v6/trainer/train
Body
- Flux LoRA
- Z-Image Turbo
- Stable Diffusion
- FLUX.2 Klein 9B
- FLUX.3 Klein
- MOSS Image
Trains a LoRA for Flux Dev. Ready to generate with on ModelsLab after training.
json
{
"key": "your_api_key",
"trainer_id": "flux_lora_trainer",
"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"
],
"trigger_word": "pinkpanda",
"hf_username": "your_hf_username",
"hf_token": "hf_your_write_token",
"training_steps": 750,
"resolution": 1024
}
Needs
training_id: the name of the Hugging Face repo the LoRA is uploaded to. Use at least 15 images for a good result. Ready to generate with on ModelsLab after training.json
{
"key": "your_api_key",
"trainer_id": "z-image-turbo-lora-trainer",
"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"
],
"trigger_word": "pinkpanda",
"hf_username": "your_hf_username",
"hf_token": "hf_your_write_token",
"training_id": "my-pinkpanda-lora",
"training_steps": 750,
"resolution": 1024
}
Uses
instance_prompt instead of trigger_word. Set base_model_type to sdxl (1024 resolution) or sd15 (512 resolution). Ready to generate with on ModelsLab after training.json
{
"key": "your_api_key",
"trainer_id": "sd-trainer",
"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"
],
"instance_prompt": "photo of sks man",
"hf_username": "your_hf_username",
"hf_token": "hf_your_write_token",
"base_model_type": "sdxl",
"training_steps": 750,
"resolution": 1024,
"seed": 298329,
"batch_size": 4,
"mixed_precision": "fp16",
"rank": 4,
"alpha": 2,
"learning_rate": 0.0001
}
Needs
training_id: the name of the Hugging Face repo the LoRA is uploaded to. Use at least 15 images for a good result. The LoRA is uploaded to your Hugging Face repo; it is not loaded for inference on ModelsLab.json
{
"key": "your_api_key",
"trainer_id": "flux2-klein-9b-lora-trainer",
"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"
],
"trigger_word": "pinkpanda",
"hf_username": "your_hf_username",
"hf_token": "hf_your_write_token",
"training_id": "my-pinkpanda-lora",
"training_steps": 750,
"resolution": 1024
}
Needs
training_id: the name of the Hugging Face repo the LoRA is uploaded to. Use at least 15 images for a good result. The LoRA is uploaded to your Hugging Face repo; it is not loaded for inference on ModelsLab.json
{
"key": "your_api_key",
"trainer_id": "flux3-klein-lora-trainer",
"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"
],
"trigger_word": "pinkpanda",
"hf_username": "your_hf_username",
"hf_token": "hf_your_write_token",
"training_id": "my-pinkpanda-lora",
"training_steps": 750,
"resolution": 1024
}
Uses
instance_prompt instead of trigger_word. learning_rate goes up to 0.01. The LoRA is uploaded to your Hugging Face repo; it is not loaded for inference on ModelsLab.json
{
"key": "your_api_key",
"trainer_id": "moss-image-lora-trainer",
"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"
],
"instance_prompt": "photo of sks man",
"hf_username": "your_hf_username",
"hf_token": "hf_your_write_token",
"training_steps": 750,
"resolution": 1024,
"seed": 298329,
"batch_size": 4,
"mixed_precision": "fp16",
"rank": 4,
"alpha": 2,
"learning_rate": 0.005
}
Response
A new run is always queued first. Keep theid: you need it to check the status or stop the run.
json
{
"status": "success",
"message": "Training request is being processed",
"data": {
"status": "pending",
"id": "9b2f6c1e-4d3a-4f8e-a1b2-3c4d5e6f7a8b",
"meta": {
"trainer_id": "flux_lora_trainer",
"images": ["https://raw.githubusercontent.com/pnavitha/sampleImages/master/1.png"],
"trigger_word": "pinkpanda",
"hf_username": "your_hf_username",
"training_steps": 750
}
},
"id": "9b2f6c1e-4d3a-4f8e-a1b2-3c4d5e6f7a8b",
"fetch_result": "https://modelslab.com/api/v6/trainer/status/9b2f6c1e-4d3a-4f8e-a1b2-3c4d5e6f7a8b"
}
Errors
Errors come back with HTTP 200 and"status": "error".
| Message | What to do |
|---|---|
Invalid trainer ID | Use one of the trainer_id values from the trainers table. |
Insufficient funds. Please top up your wallet to proceed with training. | Add at least one hour of training to your wallet. |
code: validation_error | errors lists each field that is wrong, for example an image URL that could not be downloaded or an invalid Hugging Face token. |
Body
application/json
- Flux LoRA
- FLUX.2 Klein 9B LoRA
- FLUX.3 Klein LoRA
- Z-Image Turbo LoRA
- Stable Diffusion (SDXL / SD 1.5) LoRA
- MOSS Image LoRA
Response
The run was queued, or an error describing why it was not.
Was this page helpful?

