0

Create LCM Generation

by
Published Apr 8, 2025

This endpoint will generate a LCM image generation.

Script leonardoai Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Leonardoai = {
3
  apiKey: string;
4
};
5
/**
6
 * Create LCM Generation
7
 * This endpoint will generate a LCM image generation.
8
 */
9
export async function main(
10
  auth: Leonardoai,
11
  body: {
12
    imageDataUrl: string;
13
    prompt: string;
14
    guidance?: number;
15
    strength?: number;
16
    requestTimestamp?: string;
17
    style?:
18
      | "ANIME"
19
      | "CINEMATIC"
20
      | "DIGITAL_ART"
21
      | "DYNAMIC"
22
      | "ENVIRONMENT"
23
      | "FANTASY_ART"
24
      | "ILLUSTRATION"
25
      | "PHOTOGRAPHY"
26
      | "RENDER_3D"
27
      | "RAYTRACED"
28
      | "SKETCH_BW"
29
      | "SKETCH_COLOR"
30
      | "VIBRANT"
31
      | "NONE";
32
    steps?: number;
33
    width?: number;
34
    height?: number;
35
    seed?: number;
36
  },
37
) {
38
  const url = new URL(`https://cloud.leonardo.ai/api/rest/v1/generations-lcm`);
39

40
  const response = await fetch(url, {
41
    method: "POST",
42
    headers: {
43
      "Content-Type": "application/json",
44
      Authorization: "Bearer " + auth.apiKey,
45
    },
46
    body: JSON.stringify(body),
47
  });
48
  if (!response.ok) {
49
    const text = await response.text();
50
    throw new Error(`${response.status} ${text}`);
51
  }
52
  return await response.json();
53
}
54