Skip to main content
Fine-tuning

Create a fine-tuning job

POST
/openai/v1/fine_tuning/jobs

Creates a fine-tuning job from the provided dataset and returns the enqueued job details.

Request BodyContent-Type: application/json
modelenumrequired
The name of the model to fine-tune. You can select one of the supported models.
babbage-002davinci-002gpt-3.5-turbogpt-4o-mini
training_filestringrequired
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.
hyperparametersOpenAI.CreateFineTuningJobRequestHyperparameters
The hyperparameters used for the fine-tuning job. This value is now deprecated in favor of method, and should be passed in under the method parameter.
batch_sizeenum
auto
learning_rate_multiplierenum
auto
n_epochsenum
auto
suffixstring | 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 like ft:gpt-4o-mini:openai:custom-model-name:7p4lURel.
validation_filestring | 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.
integrationsOpenAI.CreateFineTuningJobRequestIntegrations[] | null
A list of integrations to enable for your fine-tuning job.
One of the following:
OpenAI.CreateFineTuningJobRequestIntegrations[]
null
seedinteger | 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.
methodOpenAI.FineTuneMethod
The method used for fine-tuning.
typeenumrequired
The type of method. Is either supervised, dpo, or reinforcement.
superviseddporeinforcement
supervisedOpenAI.FineTuneSupervisedMethod
Configuration for the supervised fine-tuning method.
dpoOpenAI.FineTuneDPOMethod
Configuration for the DPO fine-tuning method.
reinforcementOpenAI.FineTuneReinforcementMethod
Configuration for the reinforcement fine-tuning method.
metadataOpenAI.Metadata | null
Responses
idstringrequired
The object identifier, which can be referenced in the API endpoints.
created_atintegerrequired
The Unix timestamp (in seconds) for when the fine-tuning job was created.
errorOpenAI.FineTuningJobError | nullrequired
One of the following:
OpenAI.FineTuningJobError
null
fine_tuned_modelstring | nullrequired
finished_atstring | nullrequired
hyperparametersOpenAI.FineTuningJobHyperparametersrequired
The hyperparameters used for the fine-tuning job. This value will only be returned when running supervised jobs.
batch_sizeenum
auto
learning_rate_multiplierenum
auto
n_epochsenum
auto
modelstringrequired
The base model that is being fine-tuned.
objectenumrequired
The object type, which is always "fine_tuning.job".
fine_tuning.job
organization_idstringrequired
The organization that owns the fine-tuning job.
result_filesstring[]required
The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the Files API.
statusenumrequired
The current status of the fine-tuning job, which can be either validating_files, queued, running, succeeded, failed, or cancelled.
validating_filesqueuedrunningsucceededfailedcancelled
trained_tokensinteger | nullrequired
training_filestringrequired
The file ID used for training. You can retrieve the training data with the Files API.
validation_filestring | nullrequired
integrationsOpenAI.FineTuningIntegration[] | null
One of the following:
OpenAI.FineTuningIntegration[]
null
seedintegerrequired
The seed used for the fine-tuning job.
estimated_finishstring | null
methodOpenAI.FineTuneMethod
The method used for fine-tuning.
typeenumrequired
The type of method. Is either supervised, dpo, or reinforcement.
superviseddporeinforcement
supervisedOpenAI.FineTuneSupervisedMethod
Configuration for the supervised fine-tuning method.
dpoOpenAI.FineTuneDPOMethod
Configuration for the DPO fine-tuning method.
reinforcementOpenAI.FineTuneReinforcementMethod
Configuration for the reinforcement fine-tuning method.
metadataOpenAI.Metadata | null
Request
curl https://api.openai.com/v1/fine_tuning/jobs \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo",
    "model": "gpt-4o-mini"
  }'
Response
{
  "object": "fine_tuning.job",
  "id": "ftjob-abc123",
  "model": "gpt-4o-mini-2024-07-18",
  "created_at": 1721764800,
  "fine_tuned_model": null,
  "organization_id": "org-123",
  "result_files": [],
  "status": "queued",
  "validation_file": null,
  "training_file": "file-abc123",
  "method": {
    "type": "supervised",
    "supervised": {
      "hyperparameters": {
        "batch_size": "auto",
        "learning_rate_multiplier": "auto",
        "n_epochs": "auto",
      }
    }
  },
  "metadata": null
}