0

Download model

by
Published Oct 17, 2025

Download a compressed fine-tuned model or checkpoint to local disk.

Script togetherai Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Togetherai = {
3
  api_key: string;
4
};
5
/**
6
 * Download model
7
 * Download a compressed fine-tuned model or checkpoint to local disk.
8
 */
9
export async function main(
10
  auth: Togetherai,
11
  ft_id: string | undefined,
12
  checkpoint_step: string | undefined,
13
  checkpoint: "merged" | "adapter" | undefined,
14
  output: string | undefined,
15
) {
16
  const url = new URL(`https://api.together.xyz/v1/finetune/download`);
17
  for (const [k, v] of [
18
    ["ft_id", ft_id],
19
    ["checkpoint_step", checkpoint_step],
20
    ["checkpoint", checkpoint],
21
    ["output", output],
22
  ]) {
23
    if (v !== undefined && v !== "" && k !== undefined) {
24
      url.searchParams.append(k, v);
25
    }
26
  }
27
  const response = await fetch(url, {
28
    method: "GET",
29
    headers: {
30
      Authorization: "Bearer " + auth.api_key,
31
    },
32
    body: undefined,
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40