//native
type Leonardoai = {
apiKey: string;
};
/**
* Train a Custom Model
* This endpoint will train a new custom model
*/
export async function main(
auth: Leonardoai,
body: {
name: string;
description?: string;
datasetId: string;
instance_prompt: string;
modelType?:
| "GENERAL"
| "BUILDINGS"
| "CHARACTERS"
| "ENVIRONMENTS"
| "FASHION"
| "ILLUSTRATIONS"
| "GAME_ITEMS"
| "GRAPHICAL_ELEMENTS"
| "PHOTOGRAPHY"
| "PIXEL_ART"
| "PRODUCT_DESIGN"
| "TEXTURES"
| "UI_ELEMENTS"
| "VECTOR";
nsfw?: false | true;
resolution?: number;
sd_version?: "v1_5" | "v2";
strength?: "VERY_LOW" | "LOW" | "MEDIUM" | "HIGH";
},
) {
const url = new URL(`https://cloud.leonardo.ai/api/rest/v1/models`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago