//native
type Leonardoai = {
apiKey: string;
};
/**
* Get a list of Custom Models by User ID
* This endpoint gets the list of custom models belongs to the user.
*/
export async function main(auth: Leonardoai, userId: string) {
const url = new URL(
`https://cloud.leonardo.ai/api/rest/v1/models/user/${userId}`,
);
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