0
Cancel fine tuning job
One script reply has been approved by the moderators Verified

Immediately cancel a fine-tune job.

Created by hugo697 387 days ago Viewed 9161 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 387 days ago
1
type Openai = {
2
  api_key: string;
3
  organization_id: string;
4
};
5
/**
6
 * Cancel fine tuning job
7
 * Immediately cancel a fine-tune job.
8

9
 */
10
export async function main(auth: Openai, fine_tuning_job_id: string) {
11
  const url = new URL(
12
    `https://api.openai.com/v1/fine_tuning/jobs/${fine_tuning_job_id}/cancel`
13
  );
14

15
  const response = await fetch(url, {
16
    method: "POST",
17
    headers: {
18
      "OpenAI-Organization": auth.organization_id,
19
      Authorization: "Bearer " + auth.api_key,
20
    },
21
    body: undefined,
22
  });
23
  if (!response.ok) {
24
    const text = await response.text();
25
    throw new Error(`${response.status} ${text}`);
26
  }
27
  return await response.json();
28
}
29