0

Create Texture Generation

by
Published Apr 8, 2025

This endpoint will generate a texture 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 Texture Generation
7
 * This endpoint will generate a texture generation.
8
 */
9
export async function main(
10
  auth: Leonardoai,
11
  body: {
12
    front_rotation_offset?: number;
13
    modelAssetId?: string;
14
    negative_prompt?: string;
15
    preview?: false | true;
16
    preview_direction?: string;
17
    prompt?: string;
18
    sd_version?: string;
19
    seed?: number;
20
  },
21
) {
22
  const url = new URL(
23
    `https://cloud.leonardo.ai/api/rest/v1/generations-texture`,
24
  );
25

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