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.

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: 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: 690204 - Realistic Vision v5.1

model_type (optional)

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

preset (optional)

Enum: flux-lora-fast see details in the GUI, null

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 images as multipart/form-data
# Hard coded tune id of Realistic Vision v5.1 from the gallery - https://www.astria.ai/gallery/tunes
# https://www.astria.ai/gallery/tunes/690204/prompts
curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes \
-F tune[title]="John Doe - UUID - 1234-6789-1234-56789" \
-F tune[name]=man \
-F tune[branch]="fast" \
-F tune[callback]="https://optional-callback-url.com/webhooks/astria?user_id=1&tune_id=1" \
-F tune[base_tune_id]=690204 \
-F tune[token]=ohwx \
-F "tune[prompts_attributes][0][text]=ohwx man on space circa 1979 on cover of time magazine" \
-F tune[prompts_attributes][0][callback]="https://optional-callback-url.com/webhooks/astria?user_id=1&prompt_id=1&tune_id=1" \
-F "tune[images][][email protected]" \
-F "tune[images][][email protected]" \
-F "tune[images][][email protected]" \
-F "tune[images][][email protected]"

# With image_urls as form-data
curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes \
-F tune[title]="Grumpy cat - UUID - 1234-6789-1234-56789" \
-F tune[name]=cat \
-F tune[branch]="fast" \
-F tune[callback]="https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1" \
-F tune[base_tune_id]=690204 \
-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"

# As JSON
cat > data.json <<- EOM
{
"tune": {
"title": "Grumpy Cat - 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": "ohwx cat in space circa 1979 French illustration",
"callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1"
},
{
"text": "ohwx cat getting into trouble viral meme",
"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"
]
}