//native
type Replicate = {
token: string;
};
/**
* Create a model
* Create a model.
*/
export async function main(
auth: Replicate,
body: {
cover_image_url?: string;
description?: string;
github_url?: string;
hardware: string;
license_url?: string;
name: string;
owner: string;
paper_url?: string;
visibility: "public" | "private";
},
) {
const url = new URL(`https://api.replicate.com/v1/models`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago