//native
type Leonardoai = {
apiKey: string;
};
/**
* Create a Generation of Images
* This endpoint will generate images
*/
export async function main(
auth: Leonardoai,
body: {
alchemy?: false | true;
contrastRatio?: number;
controlnets?: {
initImageId?: string;
initImageType?: "GENERATED" | "UPLOADED";
preprocessorId?: number;
weight?: number;
strengthType?: "Low" | "Mid" | "High" | "Ultra" | "Max";
}[];
elements?: { akUUID?: string; weight?: number }[];
userElements?: { userLoraId?: number; weight?: number }[];
expandedDomain?: false | true;
fantasyAvatar?: false | true;
guidance_scale?: number;
height?: number;
highContrast?: false | true;
highResolution?: false | true;
imagePrompts?: string[];
imagePromptWeight?: number;
init_generation_image_id?: string;
init_image_id?: string;
init_strength?: number;
modelId?: string;
negative_prompt?: string;
num_images?: number;
num_inference_steps?: number;
photoReal?: false | true;
photoRealVersion?: string;
photoRealStrength?: number;
presetStyle?:
| "ANIME"
| "BOKEH"
| "CINEMATIC"
| "CINEMATIC_CLOSEUP"
| "CREATIVE"
| "DYNAMIC"
| "ENVIRONMENT"
| "FASHION"
| "FILM"
| "FOOD"
| "GENERAL"
| "HDR"
| "ILLUSTRATION"
| "LEONARDO"
| "LONG_EXPOSURE"
| "MACRO"
| "MINIMALISTIC"
| "MONOCHROME"
| "MOODY"
| "NONE"
| "NEUTRAL"
| "PHOTOGRAPHY"
| "PORTRAIT"
| "RAYTRACED"
| "RENDER_3D"
| "RETRO"
| "SKETCH_BW"
| "SKETCH_COLOR"
| "STOCK_PHOTO"
| "VIBRANT"
| "UNPROCESSED";
prompt: string;
promptMagic?: false | true;
promptMagicStrength?: number;
promptMagicVersion?: string;
public?: false | true;
scheduler?:
| "LEONARDO"
| "KLMS"
| "EULER_ANCESTRAL_DISCRETE"
| "EULER_DISCRETE"
| "DDIM"
| "DPM_SOLVER"
| "PNDM";
sd_version?:
| "v1_5"
| "v2"
| "v3"
| "SDXL_0_8"
| "SDXL_0_9"
| "SDXL_1_0"
| "SDXL_LIGHTNING"
| "PHOENIX"
| "FLUX"
| "FLUX_DEV";
seed?: number;
tiling?: false | true;
transparency?: "disabled" | "foreground_only";
ultra?: false | true;
unzoom?: false | true;
unzoomAmount?: number;
upscaleRatio?: number;
width?: number;
controlNet?: false | true;
controlNetType?: "POSE" | "CANNY" | "DEPTH";
weighting?: number;
canvasRequest?: false | true;
canvasRequestType?: "INPAINT" | "OUTPAINT" | "SKETCH2IMG" | "IMG2IMG";
canvasInitId?: string;
canvasMaskId?: string;
enhancePrompt?: false | true;
enhancePromptInstruction?: string;
},
) {
const url = new URL(`https://cloud.leonardo.ai/api/rest/v1/generations`);
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