//native
type Replicate = {
token: string;
};
/**
* Update a deployment
* Update properties of an existing deployment, including hardware, min/max instances, and the deployment's underlying model [version](https://replicate.
*/
export async function main(
auth: Replicate,
deployment_owner: string,
deployment_name: string,
body: {
hardware?: string;
max_instances?: number;
min_instances?: number;
version?: string;
},
) {
const url = new URL(
`https://api.replicate.com/v1/deployments/${deployment_owner}/${deployment_name}`,
);
const response = await fetch(url, {
method: "PATCH",
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