Skip to main content
POST
/
fine-tunes
/
estimate-price
Estimate price
curl --request POST \
  --url https://api.together.ai/v1/fine-tunes/estimate-price \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "training_file": "<string>",
  "validation_file": "<string>",
  "model": "<string>",
  "n_epochs": 1,
  "n_evals": 0,
  "training_method": {
    "method": "sft",
    "train_on_inputs": "auto"
  },
  "training_type": {
    "type": "Full"
  },
  "from_checkpoint": "<string>"
}
'
import requests

url = "https://api.together.ai/v1/fine-tunes/estimate-price"

payload = {
"training_file": "<string>",
"validation_file": "<string>",
"model": "<string>",
"n_epochs": 1,
"n_evals": 0,
"training_method": {
"method": "sft",
"train_on_inputs": "auto"
},
"training_type": { "type": "Full" },
"from_checkpoint": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
training_file: '<string>',
validation_file: '<string>',
model: '<string>',
n_epochs: 1,
n_evals: 0,
training_method: {method: 'sft', train_on_inputs: 'auto'},
training_type: {type: 'Full'},
from_checkpoint: '<string>'
})
};

fetch('https://api.together.ai/v1/fine-tunes/estimate-price', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/fine-tunes/estimate-price",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'training_file' => '<string>',
'validation_file' => '<string>',
'model' => '<string>',
'n_epochs' => 1,
'n_evals' => 0,
'training_method' => [
'method' => 'sft',
'train_on_inputs' => 'auto'
],
'training_type' => [
'type' => 'Full'
],
'from_checkpoint' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.together.ai/v1/fine-tunes/estimate-price"

payload := strings.NewReader("{\n \"training_file\": \"<string>\",\n \"validation_file\": \"<string>\",\n \"model\": \"<string>\",\n \"n_epochs\": 1,\n \"n_evals\": 0,\n \"training_method\": {\n \"method\": \"sft\",\n \"train_on_inputs\": \"auto\"\n },\n \"training_type\": {\n \"type\": \"Full\"\n },\n \"from_checkpoint\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.together.ai/v1/fine-tunes/estimate-price")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"training_file\": \"<string>\",\n \"validation_file\": \"<string>\",\n \"model\": \"<string>\",\n \"n_epochs\": 1,\n \"n_evals\": 0,\n \"training_method\": {\n \"method\": \"sft\",\n \"train_on_inputs\": \"auto\"\n },\n \"training_type\": {\n \"type\": \"Full\"\n },\n \"from_checkpoint\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.together.ai/v1/fine-tunes/estimate-price")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"training_file\": \"<string>\",\n \"validation_file\": \"<string>\",\n \"model\": \"<string>\",\n \"n_epochs\": 1,\n \"n_evals\": 0,\n \"training_method\": {\n \"method\": \"sft\",\n \"train_on_inputs\": \"auto\"\n },\n \"training_type\": {\n \"type\": \"Full\"\n },\n \"from_checkpoint\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "estimation_available": true,
  "estimated_total_price": 123,
  "allowed_to_proceed": true,
  "user_limit": 123,
  "estimated_train_token_count": 123,
  "estimated_eval_token_count": 123
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}

Authorizations

Authorization
string
header
default:default
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
training_file
string
required

File-ID of a training file uploaded to the Together API

validation_file
string

File-ID of a validation file uploaded to the Together API

model
string

Name of the base model to run fine-tune job on

n_epochs
integer
default:1

Number of complete passes through the training dataset (higher values may improve results but increase cost and risk of overfitting)

n_evals
integer
default:0

Number of evaluations to be run on a given validation set during training

training_method
object

The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization.

training_type
object

The training type to use. Defaults to LoRA if not provided.

from_checkpoint
string

The checkpoint identifier to continue training from a previous fine-tuning job. Format is {$JOB_ID} or {$OUTPUT_MODEL_NAME} or {$JOB_ID}:{$STEP} or {$OUTPUT_MODEL_NAME}:{$STEP}. The step value is optional; without it, uses the final checkpoint.

Response

Price estimated successfully

estimation_available
enum<boolean>
required

Whether price estimation is available for the requested fine-tune job.

Available options:
true
estimated_total_price
number

The price of the fine-tuning job

allowed_to_proceed
boolean

Whether you are allowed to proceed with the fine-tuning job.

Example:

true

user_limit
number

Your credit limit in dollars.

estimated_train_token_count
number

The estimated number of tokens to be trained

estimated_eval_token_count
number

The estimated number of tokens for evaluation