0
Retrieve fine tune
One script reply has been approved by the moderators Verified

Gets info about the fine-tune job.

Learn more about fine-tuning

Created by hugo697 156 days ago Viewed 5534 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 156 days ago
1
type Openai = {
2
  api_key: string;
3
  organization_id: string;
4
};
5
/**
6
 * Retrieve fine tune
7
 * Gets info about the fine-tune job.
8

9
Learn more about fine-tuning
10

11
 */
12
export async function main(auth: Openai, fine_tune_id: string) {
13
  const url = new URL(`https://api.openai.com/v1/fine-tunes/${fine_tune_id}`);
14

15
  const response = await fetch(url, {
16
    method: "GET",
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