0
List fine tunes
One script reply has been approved by the moderators Verified

List your organization's fine-tuning jobs

Created by hugo697 166 days ago Viewed 6463 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 166 days ago
1
type Openai = {
2
  api_key: string;
3
  organization_id: string;
4
};
5
/**
6
 * List fine tunes
7
 * List your organization's fine-tuning jobs
8

9
 */
10
export async function main(auth: Openai) {
11
  const url = new URL(`https://api.openai.com/v1/fine-tunes`);
12

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