//native
type Leonardoai = {
apiKey: string;
};
/**
* List Elements
* Get a list of public Elements available for use with generations.
*/
export async function main(auth: Leonardoai) {
const url = new URL(`https://cloud.leonardo.ai/api/rest/v1/elements`);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago