0

Create SVD Motion Generation

by
Published Apr 8, 2025

This endpoint will generate a SVD motion 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 SVD Motion Generation
7
 * This endpoint will generate a SVD motion generation.
8
 */
9
export async function main(
10
  auth: Leonardoai,
11
  body: {
12
    imageId: string;
13
    isPublic?: false | true;
14
    isInitImage?: false | true;
15
    isVariation?: false | true;
16
    motionStrength?: number;
17
  },
18
) {
19
  const url = new URL(
20
    `https://cloud.leonardo.ai/api/rest/v1/generations-motion-svd`,
21
  );
22

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