Retrieve fine tuning job

Get info about a fine-tuning job. Learn more about fine-tuning

Script openai Verified

by hugo697 ยท 12/1/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 372 days ago
1
type Openai = {
2
  api_key: string;
3
  organization_id: string;
4
};
5
/**
6
 * Retrieve fine tuning job
7
 * Get info about a fine-tuning job.
8

9
Learn more about fine-tuning
10

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

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