Create fine-tuning job
Creates a fine-tuning job which begins the process of creating a new model from a given dataset.
Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
Request body
model
string
The name of the model to fine-tune. You can select one of the supported models.
model
string
Required
model
string
Required
babbage-002
string
davinci-002
string
gpt-3.5-turbo
string
gpt-4o-mini
string
training_file
string
Required
The ID of an uploaded file that contains training data.
See upload file for how to upload a file.
Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose
fine-tune
.The contents of the file should differ depending on if the model uses the chat, completions format, or if the fine-tuning method uses the preference format.
See the fine-tuning guide for more details.
hyperparameters
object
Deprecated
The hyperparameters used for the fine-tuning job. This value is now deprecated in favor of
method
, and should be passed in under themethod
parameter.batch_size
string or integer
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.batch_size
string
auto
string
batch_size
integer
learning_rate_multiplier
string or number
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.learning_rate_multiplier
string
auto
string
learning_rate_multiplier
number
n_epochs
string or integer
The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.n_epochs
string
auto
string
n_epochs
integer
suffix
string or null
Defaults: null
A string of up to 64 characters that will be added to your fine-tuned model name.
For example, a
suffix
of "custom-model-name" would produce a model name likeft:gpt-4o-mini:openai:custom-model-name:7p4lURel
.validation_file
string or null
The ID of an uploaded file that contains validation data.
If you provide this file, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in the fine-tuning results file. The same data should not be present in both train and validation files.
Your dataset must be formatted as a JSONL file. You must upload your file with the purpose
fine-tune
.See the fine-tuning guide for more details.
integrations
array or null
A list of integrations to enable for your fine-tuning job.items
object
type
string
The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported.type
string
Required
wandb
string
wandb
object
Required
The settings for your integration with Weights and Biases. This payload specifies the project that metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags to your run, and set a default entity (team, username, etc) to be associated with your run.project
string
Required
The name of the project that the new run will be created under.name
string or null
A display name to set for the run. If not set, we will use the Job ID as the name.entity
string or null
The entity to use for the run. This allows you to set the team or username of the WandB user that you would like associated with the run. If not set, the default entity for the registered WandB API key is used.tags
array
A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".items
string
seed
integer or null
The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. If a seed is not specified, one will be generated for you.method
object
The method used for fine-tuning.type
string
The type of method. Is either
supervised
ordpo
.supervised
string
dpo
string
supervised
object
Configuration for the supervised fine-tuning method.hyperparameters
object
The hyperparameters used for the fine-tuning job.batch_size
string or integer
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.batch_size
string
auto
string
batch_size
integer
learning_rate_multiplier
string or number
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.learning_rate_multiplier
string
auto
string
learning_rate_multiplier
number
n_epochs
string or integer
The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.n_epochs
string
auto
string
n_epochs
integer
dpo
object
Configuration for the DPO fine-tuning method.hyperparameters
object
The hyperparameters used for the fine-tuning job.beta
string or number
The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.beta
string
auto
string
beta
number
batch_size
string or integer
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.batch_size
string
auto
string
batch_size
integer
learning_rate_multiplier
string or number
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.learning_rate_multiplier
string
auto
string
learning_rate_multiplier
number
n_epochs
string or integer
The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.n_epochs
string
auto
string
n_epochs
integer
metadata
object or null
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
Response
A fine-tuning.job object.
1 curl https://api.openai.com/v1/fine_tuning/jobs \2 -H "Content-Type: application/json" \3 -H "Authorization: Bearer $OPENAI_API_KEY" \4 -d '{5 "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo",6 "model": "gpt-4o-mini"7 }'
1 {2 "object": "fine_tuning.job",3 "id": "ftjob-abc123",4 "model": "gpt-4o-mini-2024-07-18",5 "created_at": 1721764800,6 "fine_tuned_model": null,7 "organization_id": "org-123",8 "result_files": [],9 "status": "queued",10 "validation_file": null,11 "training_file": "file-abc123",12 "method": {13 "type": "supervised",14 "supervised": {15 "hyperparameters": {16 "batch_size": "auto",17 "learning_rate_multiplier": "auto",18 "n_epochs": "auto",19 }20 }21 },22 "metadata": null23 }