Sample - OpenAI API
POST/fine_tuning/jobs

Create a fine-tuning job

Creates a fine-tuning job that begins training a new model from an uploaded dataset. Supply model and training_file, and optionally configure validation, fine-tuning methods, hyperparameters, integrations, a suffix, seed, and metadata. The response contains the enqueued job and its current status; poll the fine-tuning job resource for progress.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

9 body fields

Fine-tuning job configuration containing the base model, training dataset, and optional validation and optimization settings.

modelstringrequired
The name of the model to fine-tune. You can select one of the [supported models](https://developers.openai.com/api/docs/guides/model-optimization#fine-tuning-methods).
training_filestringrequired
The ID of an uploaded file that contains training data. See [upload file](https://developers.openai.com/api/reference/resources/files/methods/create) 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](https://developers.openai.com/api/docs/guides/supervised-fine-tuning#formatting-your-data), [completions](https://developers.openai.com/api/docs/guides/supervised-fine-tuning#formatting-your-data) format, or if the fine-tuning method uses the [preference](https://developers.openai.com/api/docs/guides/direct-preference-optimization) format. See the [fine-tuning guide](https://developers.openai.com/api/docs/guides/model-optimization) for more details.
hyperparametersobjectdeprecatedoptional
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.
suffixstringoptional
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`.
Default:null
validation_filestringoptional
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](https://developers.openai.com/api/docs/guides/model-optimization) for more details.
integrationsarray<object>optional
A list of integrations to enable for your fine-tuning job.
seedintegeroptional
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.
methodobjectoptional
The method used for fine-tuning.
metadataobjectoptional
Optional string key-value metadata attached to the fine-tuning job, or null.

1 status code
200Returns the created fine-tuning job, including its identifier, base model, training file, current status, organization, result files, and completion details.
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.
errorobjectrequired
For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure.
fine_tuned_modelstringrequired
The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running.
finished_atintegerrequired
The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running.
hyperparametersobjectrequired
The hyperparameters used for the fine-tuning job. This value will only be returned when running `supervised` jobs.
modelstringrequired
The base model that is being fine-tuned.
objectstringrequired
The object type, which is always "fine_tuning.job".
Allowed:fine_tuning.job
organization_idstringrequired
The organization that owns the fine-tuning job.
result_filesarray<string>required
The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](https://developers.openai.com/api/reference/resources/files/methods/content).
statusstringrequired
The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
Allowed:validating_filesqueuedrunningsucceededfailedcancelled
trained_tokensintegerrequired
The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running.
training_filestringrequired
The file ID used for training. You can retrieve the training data with the [Files API](https://developers.openai.com/api/reference/resources/files/methods/content).
validation_filestringrequired
The file ID used for validation. You can retrieve the validation results with the [Files API](https://developers.openai.com/api/reference/resources/files/methods/content).
integrationsarray<FineTuningJobIntegration>optional
A list of integrations to enable for this fine-tuning job.
seedintegerrequired
The seed used for the fine-tuning job.
estimated_finishintegeroptional
The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running.
methodobjectoptional
The method used for fine-tuning.
metadataobjectoptional
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.

Error handling

model and training_file are required. training_file must identify an uploaded JSONL file whose purpose is fine-tune; method.type must be supervised, dpo, or reinforcement, and a reinforcement method must include grader. seed must be between 0 and 2147483647, while suffix must contain 1 to 64 characters.