//native
type Replicate = {
token: string;
};
/**
* Create a deployment
* Create a new deployment:
Example cURL request:
```console
curl -s \
-X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-app-image-generator",
"model": "stability-ai/sdxl",
"version": "da77bc59ee60423279fd632efb4795ab731d9e3ca9705ef3341091fb989b7eaf",
"hardware": "gpu-t4",
"min_instances": 0,
"max_instances": 3
}' \
https://api.
*/
export async function main(
auth: Replicate,
body: {
hardware: string;
max_instances: number;
min_instances: number;
model: string;
name: string;
version: string;
},
) {
const url = new URL(`https://api.replicate.com/v1/deployments`);
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.json();
}
Submitted by hugo697 235 days ago