Skip to main content

Create a tune from a pack

Creates a new fine-tune model from training images according to the pack base tune id, model type and adds prompts to generate images.

Parameters

name (required)

A class name the describes the fine-tune. e.g: man, woman, cat, dog, boy, girl, style. Class name must be supported by pack.

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.

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.callback (optional)

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

Returns

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

POST /p/:pack_id/tunes

# With images as multipart/form-data
# Hard coded pack id 43 for corporate headshots from the gallery - https://www.astria.ai/gallery/packs
# https://www.astria.ai/gallery/tunes/690204/prompts
curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/p/43/tunes \
-F tune[title]="John Doe - UUID - 1234-6789-1234-56789" \
-F tune[name]=man \
-F tune[callback]="https://optional-callback-url.com/webhooks/astria?user_id=1" \
-F tune[characteristics][eye_color]="blue eyes" \
-F tune[prompt_attributes][callback]="https://optional-callback-url.com/webhooks/astria_prompts?user_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/p/43/tunes \
-F tune[title]="Grumpy cat - UUID - 1234-6789-1234-56789" \
-F tune[name]=cat \
-F tune[callback]="https://optional-callback-url.com/to-your-service-when-ready?user_id=1" \
-F tune[prompt_attributes][callback]="https://optional-callback-url.com/webhooks/astria_prompts?user_id=1" \
-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",
"callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1",
"characteristics": {"eye_color": "blue eyes"},
"prompt_attributes": {
"callback": "https://optional-callback-url.com/webhooks/astria_prompts?user_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"
]
}
}
EOM

# Hard coded pack id 43 for corporate headshots from the gallery - https://www.astria.ai/gallery/packs
curl -X POST -H"Content-Type: application/json" -H "Authorization: Bearer $API_KEY" --data @data.json https://api.astria.ai/p/43/tunes

Response


{
"id": 1,
"title": "John Doe",
"name": "woman",
"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",
"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"
]
}