//native
type Lumaai = {
apiKey: string;
};
/**
* Generate an image
* Generate an image with the provided prompt
*/
export async function main(
auth: Lumaai,
body: {
generation_type?: "image";
model?: "photon-1" | "photon-flash-1";
prompt?: string;
aspect_ratio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "21:9" | "9:21";
callback_url?: string;
image_ref?: { url?: string; weight?: number }[];
style_ref?: { url?: string; weight?: number }[];
character_ref?: { identity0?: { images?: string[] } };
modify_image_ref?: { url?: string; weight?: number };
},
) {
const url = new URL(
`https://api.lumalabs.ai/dream-machine/v1/generations/image`,
);
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