0

Delete a model

by
Published Oct 17, 2025

Delete a model Model deletion has some restrictions: - You can only delete models you own.

Script replicate Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Replicate = {
3
  token: string;
4
};
5
/**
6
 * Delete a model
7
 * Delete a model
8

9
Model deletion has some restrictions:
10

11
- You can only delete models you own.
12
 */
13
export async function main(
14
  auth: Replicate,
15
  model_owner: string,
16
  model_name: string,
17
) {
18
  const url = new URL(
19
    `https://api.replicate.com/v1/models/${model_owner}/${model_name}`,
20
  );
21

22
  const response = await fetch(url, {
23
    method: "DELETE",
24
    headers: {
25
      Authorization: "Bearer " + auth.token,
26
    },
27
    body: undefined,
28
  });
29
  if (!response.ok) {
30
    const text = await response.text();
31
    throw new Error(`${response.status} ${text}`);
32
  }
33
  return await response.text();
34
}
35