Delete an assistant file.
1
type Openai = {
2
api_key: string;
3
organization_id: string;
4
};
5
/**
6
* Delete assistant file
7
* Delete an assistant file.
8
*/
9
export async function main(
10
auth: Openai,
11
assistant_id: string,
12
file_id: string
13
) {
14
const url = new URL(
15
`https://api.openai.com/v1/assistants/${assistant_id}/files/${file_id}`
16
);
17
18
const response = await fetch(url, {
19
method: "DELETE",
20
headers: {
21
"OpenAI-Organization": auth.organization_id,
22
Authorization: "Bearer " + auth.api_key,
23
},
24
body: undefined,
25
});
26
if (!response.ok) {
27
const text = await response.text();
28
throw new Error(`${response.status} ${text}`);
29
}
30
return await response.json();
31
32