Skip to main content

Create a tune

Creates a new fine-tune model from training images which in turn will be used to create prompts and generate images.

info

To avoid cloning inference details of different model types such as Flux LoRA vs SD1.5 checkpoint, please consider using the Packs API. Packs will help you abstract the inference logic so that you do not have to hard-code prompts and parameters such as w,h, cfg_scale in your backend. Moreover this will allow the creative department to launch packs, make modifications and even track likes, without needing to touch the backend code.

Parameters

name (required)

A class name the describes the fine-tune. e.g: man, woman, cat, dog, boy, girl, style

title (required)

Describes the fine-tune. Ideally a UUID related to the transaction. See idempotency for more information.

images (required)

An array of images to train the fine-tune with. The images can be uploaded as multipart/form-data or as image_urls.

image_urls (required)

An array of images to train the fine-tune with. The images can be uploaded as multipart/form-data or as image_urls.

callback (optional)

A webhook URL to be called when the tune is finished training. The webhook will receive a POST request with the tune object. See more on callbacks.

branch (optional)

Enum: flux1,sd15, sdxl1, fast. Will default to the base_tune branch if not specified, or to sd15 if base_tune is not specified.

info

Use branch=fast for mock testing

steps (optional)

Training steps. Recommended leaving blank in order to allow better defaults set by the system.

token (optional)

Unique short text to which the features will be embedded into. Default ohwx for SDXL and sks for SD15.

face_crop (optional)

Detects faces in training images and augments training set with cropped faces. Defaults to account setting

training_face_correct (optional)

Enhance training images using GFPGAN. Consider enabling if input image are low quality or low resolution. May result in over-smoothing.

base_tune_id (optional)

Training on top of former fine-tune or a different baseline model from the gallery (id in the URL). e.g: 1504944 - Flux1.dev

model_type (optional)

Enum: lora, pti, faceid, null for checkpoint. For SDXL1 - API will default to pti and will ignore model_type parameter.

auto_extend (optional)

Boolean: true, false. If true, the tune will be automatically extended when it expires. Default is false. See pricing.

preset (optional)

Enum: flux-lora-focus, flux-lora-portrait, flux-lora-fast see details in the GUI, null. See Flux lora training for more information.

characteristics (optional)

A free-form object that can be used to templatize the prompts text. e.g: {"eye_color": "blue eyes"} would than be used in the prompt text as ohwx woman, {{eye_color}}, holding flowers.

prompts_attributes (optional)

Array of prompts entities with all attributes. See create prompt for more information.

Returns

Returns a tune object if successful which will start training immediately and call callback once training is complete.

POST /tunes

# With imags as multipart/form-data
# Hard coded tune id of Flux1.dev - https://www.astria.ai/gallery/tunes
curl -X POST -H "Authorization: Bearer $API_KEY" http://localhost:3000/tunes \
-F "tune[title]=Jane Doe - UUID - 1234-6789-1234-56789" \
-F "tune[name]=woman" \
-F "tune[base_tune_id]=1504944" \
-F "tune[model_type]=lora" \
-F "tune[token]=ohwx" \
-F "tune[images][][email protected]" \
-F "tune[images][][email protected]" \
-F "tune[images][][email protected]" \
-F "tune[images][][email protected]" \
-F "tune[prompts_attributes][][text]=ohwx woman holding flowers" \
-F "tune[prompts_attributes][][inpaint_faces]=true" \
-F "tune[prompts_attributes][][super_resolution]=true"

# With image_urls as form-data
# Hard coded tune id of Flux1.dev - https://www.astria.ai/gallery/tunes
curl -X POST -H "Authorization: Bearer $API_KEY" http://localhost:3000/tunes \
-F "tune[title]=Jane Doe - UUID - 1234-6789-1234-56789" \
-F "tune[name]=woman" \
-F "tune[base_tune_id]=1504944" \
-F "tune[model_type]=lora" \
-F "tune[token]=ohwx" \
-F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \
-F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \
-F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \
-F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \
-F "tune[prompts_attributes][][text]=ohwx woman holding flowers" \
-F "tune[prompts_attributes][][inpaint_faces]=true" \
-F "tune[prompts_attributes][][super_resolution]=true"

# As JSON
cat > data.json <<- EOM
{
"tune": {
"title": "Jane Doe - UUID - 1234-6789-1234-56789",
"name": "cat",
"branch": "fast",
"callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1",
"image_urls": [
"https://i.imgur.com/HLHBnl9.jpeg",
"https://i.imgur.com/HLHBnl9.jpeg",
"https://i.imgur.com/HLHBnl9.jpeg",
"https://i.imgur.com/HLHBnl9.jpeg"
],
"prompts_attributes": [
{
"text": "<lora...> ohwx woman holding flowers",
"callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1"
}
]
}
}
EOM

curl -X POST -H"Content-Type: application/json" -H "Authorization: Bearer $API_KEY" --data @data.json https://api.astria.ai/tunes

Response


{
"id": 1,
"title": "John Doe - UUID - 1234-6789-1234-56789",
"name": "woman",
"token": "ohwx",
"base_tune_id": null,
"args": null,
"steps": null,
"face_crop": null,
"training_face_correct": false,
"ckpt_url": "https://sdbooth2-production.s3.amazonaws.com/mock",
"ckpt_urls": [
"https://sdbooth2-production.s3.amazonaws.com/mock"
],
"eta": "2023-10-02T14:32:40.363Z",
"trained_at": "2023-10-02T14:32:40.363Z",
"started_training_at": "2023-10-02T14:32:05.229Z",
"expires_at": "2023-11-01T14:32:40.363Z",
"created_at": "2023-10-02T14:32:05.067Z",
"branch": "sdxl1",
"model_type": "lora",
"updated_at": "2023-10-02T14:32:40.363Z",
"url": "https://www.astria.ai/tunes/788416.json",
"orig_images": [
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock",
"https://sdbooth2-production.s3.amazonaws.com/mock"
]
}