//native
type Lumaai = {
apiKey: string;
};
/**
* Create a generation
* Initiate a new generation with the provided prompt
*/
export async function main(
auth: Lumaai,
body: {
generation_type?: "video";
prompt?: string;
aspect_ratio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "21:9" | "9:21";
loop?: false | true;
keyframes?: {
frame0?:
| { type: "generation"; id: string }
| { type: "image"; url: string };
frame1?:
| { type: "generation"; id: string }
| { type: "image"; url: string };
};
callback_url?: string;
model?: "ray-1-6" | "ray-2" | "ray-flash-2";
resolution?: string;
duration?: string;
},
) {
const url = new URL(`https://api.lumalabs.ai/dream-machine/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 235 days ago