Flux fine Tuning API
This documentation outlines the API endpoints for initiating and managing Flux fine-tuning requests in Segmind.
Base URL
https://api.segmind.com
Authentication
All requests require an API key for authentication. Include the API key in the headers as follows:
--header 'x-api-key: YOUR_API_KEY'
1. Initiate Fine-Tune Request
Description
Initiate a new fine-tuning request.
Request
Headers
x-api-key
: Your API key.Content-Type
: Should beapplication/json
.
GPU Selection
machine_type: Specifies the GPU used for the fine-tuning job
Purpose: Defines the hardware performance tier for training in request submit endpoint
Options: "NVIDIA_A100_40GB", "NVIDIA_H100", "NVIDIA_L40S"
Descriptions:
- NVIDIA_A100_40GB (Balanced performance)
- NVIDIA_H100 (Fastest training)
- NVIDIA_L40S (Cost-efficient)
Body
The request body must be in JSON format. Here's an example:
curl --location 'https://api.segmind.com/finetune/request/submit' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"name": "fluxtest1",
"data_source_path": "https://finetune-pipeline.s3.amazonaws.com/uploads/b15e76a9-0037-4fcf-8522-fdaab460e206/54c7783e-7ac4-437d-a449-89a2613f1dc8-1MAN-Man-Dec-2023.zip",
"instance_prompt": "1MAN, running in brown suit",
"trigger_word": "1MAN",
"base_model": "FLUX",
"train_type": "LORA",
"machine_type": "NVIDIA_A100_40GB",
"theme": "FLUX",
"segmind_public": false,
"advance_parameters": {
"auto_caption": true,
"batch_size": 2,
"bucket_steps": 64,
"center_crop": false,
"content_or_style": "balanced",
"gradient_accumulation_steps": 2,
"learning_rate": 0.0004,
"linear": 16,
"linear_alpha": 16,
"lora_rank": 128,
"lr_scheduler": "constant",
"max_grad_norm": 0,
"noise_offset": 0,
"num_train_epochs": 1000,
"optimizer_type": "Adafactor",
"prompt": "driving a truck",
"relative_step": false,
"repeats": 100,
"resolution": 1024,
"steps": 1000,
"weight_decay": 0.01
}
}'
2. Get the List of Fine-Tune Requests
Description
Retrieve a list of fine-tuning requests along with their details.
Request
curl --location 'https://api.segmind.com/finetune/request/list' \
--header 'x-api-key: YOUR_API_KEY'
3. Get Fine-Tune Data Upload Pre-Signed URL
Description
Get a pre-signed URL for uploading fine-tuning data.
Request
curl --location --request GET 'https://api.segmind.com/finetune/request/upload/pre-signed-url' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"name": "NAME_OF_THE_FILE"
}'
4. Update Fine-Tuned Model Access
Description
Update the access settings of a fine-tuned model (public/private).
Request
curl --location --request PUT 'https://api.segmind.com/finetune/request/access-update' \
--header 'x-api-key: YOUR_API_KEY' \
--form 'request_id="FINETUNE_REQUEST_ID"' \
--form 'segmind_public="True"'
5. Download the Fine-Tuned Safetensor File
Description
Download the fine-tuned model file.
Request
curl --location --request GET 'https://api.segmind.com/finetune/request/file/download' \
--header 'x-api-key: YOUR_API_KEY' \
--form 'cloud_storage_url="CLOUD_STORAGE_URL"'
Webhooks
Webhooks provide a way to get real-time updates about finetuning jobs programmatically. You can register a webhook for finetuning jobs in the Developer tab on console.
Once a webhook is created, test it, by having it send a sample payload to verify delivery. Once its up, create a finetuning job to receive status updates. Events are sent to webhooks on 3 status changes:\
TRAINING_COMPLETED
: The training is completed on model, and finetuned model is available for download on thetrained_model_url
.INFERENCE_QUEUED
: Model is being deployed on Segmind inference engine.AVAILABLE
: Model is deployed, and ready for inferences oninference_api_url
Note: You can create only 1 webhook at a time for finetune jobs. If you want to change the webhook, please delete the old webhook before creating a new one.
Last updated