API reference · Fine-tuning
Price estimate for fine-tuning on a validated dataset
/v1/fine-tunes/estimate- TypeScript
client.fineTuning.estimate()- Python
client.fine_tuning.estimate()- CLI
hayonix fine-tunes estimate
Checks the model, files and settings as creating a job would, and returns the estimated billable tokens, their cost and the credit a job would reserve. Nothing is created or charged; the files must have finished validation.
Project API key (Authorization: Bearer sk_…), or a console session. Requires the fine_tune_job:read permission (a key's scope, or a role that includes it).
Examples
The samples read API_KEY and API_BASE_URL from the environment (see Setup). Values are examples.
curl -sS "$API_BASE_URL/fine-tunes/estimate?model=%3Cmodel%3E&training_file_id=file_01jc5zq4m8k3v6x9t2w7r0b1e4" \
-H "Authorization: Bearer $API_KEY"Request
| Header | Required | Description |
|---|---|---|
Authorization | yes | Bearer and your API key. The key implies its project. |
X-Project-Id | session only | The project to act in, for console sessions. Requests with an API key leave it out. |
Query parameters
modelstringrequiredA fine-tunable base model: slug or ID
1–200 characters
training_file_idstringrequiredID of the training file
ID with prefix file_
validation_file_idstringID of the validation file
ID with prefix file_
methodstringTraining method (default supervised)
One of
supervisedpreferenceadapterstringAdapter type (default lora)
One of
lorafullepochsintegerPasses over the training file (default 1)
1–20
evals_per_epochinteger | nullEvaluations of the validation file per epoch (default 1)
0–20
skustringHardware SKU the job would train on (default: the base model's first listed SKU); checked, but it does not change the price
1–64 characters
Response
200 FineTuneEstimate — The estimate, from the price book in force
objectstringrequiredAlways `fine_tune_estimate`: the type of this object
One of
fine_tune_estimatemodelstringrequiredModel ID (`publisher/name`)
training_tokensintegerrequiredepochs × training-file tokens
evaluation_tokensintegerrequiredepochs × evaluations per epoch × validation-file tokens
billable_tokensintegerrequired`training_tokens` plus `evaluation_tokens`: what the estimate prices
ShowHide 5 fields of
priceunit_pricestringrequiredInteger nano-USD as a decimal string
pattern ^-?[0-9]+$
unit_quantitystringrequiredTokens the unit price is for
per_million_tokensstringrequiredInteger nano-USD as a decimal string
pattern ^-?[0-9]+$
display_unitstring | nullrequiredLabel of the unit for display; null when none is set
price_book_versionintegerrequiredVersion of the price book the price comes from
estimated_coststringrequiredInteger nano-USD as a decimal string
pattern ^-?[0-9]+$
reservationstringrequiredCredit reserved when the job is created (released down to the actual charge at the end)
pattern ^-?[0-9]+$
token_estimate_methodstringrequiredHow file tokens were estimated: characters divided by 4, plus the model's per-example template overhead. The job is billed on the exact count.
One of
characters_div_4
Example response
{
"object": "fine_tune_estimate",
"model": "string",
"training_tokens": 1,
"evaluation_tokens": 1,
"billable_tokens": 1,
"price": {
"unit_price": "1500000000",
"unit_quantity": "string",
"per_million_tokens": "1500000000",
"display_unit": "string",
"price_book_version": 1
},
"estimated_cost": "1500000000",
"reservation": "1500000000",
"token_estimate_method": "characters_div_4"
}Errors
Errors use the standard envelope. What this operation can answer:
| Status | Type | When |
|---|---|---|
400 | invalid_request_error | A parameter or body field is missing or not allowed; param names it. |
401 | authentication_error | The key or session is missing, revoked or expired. |
403 | permission_error | The credential lacks the permission this needs, or the organization is suspended. |
402 | insufficient_credit_error | The organization is out of credit or over a spend limit. |
429 | rate_limit_error rate_limited | Too many requests; retry after retry-after seconds. |