Flux Kontext fine tuning API

This documentation outlines the API endpoints for initiating and managing Flux Kontext 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 be application/json.

Dataset (data_source_path)

  • data_source_path: A URL pointing to a ZIP file containing your training dataset. Purpose: Specifies the dataset source for fine-tuning. Must be a valid public URL or a private Segmind URL. Options: "Public ZIP URL (must support GET & HEAD requests)", "Segmind Private URL using Presigned" Descriptions: - Public ZIP URL: Must be directly accessible and respond properly to both HEAD and GET requests with headers like Content-Length. - Segmind Presigned URL: Use Segmind Presigned URL endpoint to upload as private zip file

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_H100" Descriptions: - NVIDIA_H100 (Fastest training) \

Body

The request body must be in JSON format.

Request

Sample Response

2. Get the Details of Individual Fine-Tune Request

Description

Retrieve a fine-tuning request along with details.

Request

Sample Response

3. Get the List of Fine-Tune Requests

Description

Retrieve a list of fine-tuning requests along with their details.

Request

Sample Response

4. Get Fine-Tune Data Upload Pre-Signed URL

Description

Obtain a pre-signed URL to securely upload fine-tuning data to cloud storage. This URL allows you to upload data directly from your local system or application without needing AWS credentials.

Usage

Call this endpoint to generate a temporary pre-signed URL. Use the returned URL to upload your dataset file to the specified location via a PUT request.

Request

Sample Response

5. Update Fine-Tuned Model Access

Description

Update the access settings of a fine-tuned model (public/private).

Request

Sample Response

6. Download the Fine-Tuned Safetensor File

Description

Generate a time-limited pre-signed URL to securely download the fine-tuned model file (.safetensors) from cloud storage. The URL is valid for 1 hour and allows direct download without requiring AWS credentials.

Request

Sample Response

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:\

  1. TRAINING_COMPLETED : The training is completed on model, and finetuned model is available for download on the trained_model_url.

  2. INFERENCE_QUEUED: Model is being deployed on Segmind inference engine.

  3. AVAILABLE: Model is deployed, and ready for inferences on inference_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