0

Create job

by
Published Oct 17, 2025

Use a model to create a fine-tuning job.

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
 * Create job
7
 * Use a model to create a fine-tuning job.
8
 */
9
export async function main(
10
  auth: Togetherai,
11
  body: {
12
    training_file: string;
13
    validation_file?: string;
14
    model: string;
15
    n_epochs?: number;
16
    n_checkpoints?: number;
17
    n_evals?: number;
18
    batch_size?: number;
19
    learning_rate?: number;
20
    lr_scheduler?: string;
21
    warmup_ratio?: number;
22
    max_grad_norm?: number;
23
    weight_decay?: number;
24
    suffix?: string;
25
    wandb_api_key?: string;
26
    wandb_base_url?: string;
27
    wandb_project_name?: string;
28
    wandb_name?: string;
29
    train_on_inputs?: false | true;
30
    training_type?:
31
      | { type: "Full" }
32
      | {
33
          type: "Lora";
34
          lora_r: number;
35
          lora_alpha: number;
36
          lora_dropout?: number;
37
          lora_trainable_modules?: string;
38
        };
39
  },
40
) {
41
  const url = new URL(`https://api.together.xyz/v1/fine-tunes`);
42

43
  const response = await fetch(url, {
44
    method: "POST",
45
    headers: {
46
      "Content-Type": "application/json",
47
      Authorization: "Bearer " + auth.api_key,
48
    },
49
    body: JSON.stringify(body),
50
  });
51
  if (!response.ok) {
52
    const text = await response.text();
53
    throw new Error(`${response.status} ${text}`);
54
  }
55
  return await response.json();
56
}
57