//native
type Leonardoai = {
apiKey: string;
};
/**
* Get user information
* This endpoint will return your user information such as your user id, username, token renewal date and current amounts of the following: subscription tokens, gpt (prompt generation) tokens, and model training tokens
*/
export async function main(auth: Leonardoai) {
const url = new URL(`https://cloud.leonardo.ai/api/rest/v1/me`);
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