0

Create using Universal Upscaler

by
Published Apr 8, 2025

This endpoint will create a high resolution image using Universal Upscaler

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 using Universal Upscaler
7
 * This endpoint will create a high resolution image using Universal Upscaler
8
 */
9
export async function main(
10
  auth: Leonardoai,
11
  body: {
12
    creativityStrength?: number;
13
    detailContrast?: number;
14
    generatedImageId?: string;
15
    initImageId?: string;
16
    prompt?: string;
17
    similarity?: number;
18
    ultraUpscaleStyle?: "ARTISTIC" | "REALISTIC";
19
    upscaleMultiplier?: number;
20
    upscalerStyle?:
21
      | "GENERAL"
22
      | "CINEMATIC"
23
      | "2D ART & ILLUSTRATION"
24
      | "CG ART & GAME ASSETS";
25
    variationId?: string;
26
  },
27
) {
28
  const url = new URL(
29
    `https://cloud.leonardo.ai/api/rest/v1/variations/universal-upscaler`,
30
  );
31

32
  const response = await fetch(url, {
33
    method: "POST",
34
    headers: {
35
      "Content-Type": "application/json",
36
      Authorization: "Bearer " + auth.apiKey,
37
    },
38
    body: JSON.stringify(body),
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.json();
45
}
46