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.
ParametersExpand Collapse
JobCreateParams params
Model modelThe name of the model to fine-tune. You can select one of the
supported models.
The name of the model to fine-tune. You can select one of the supported models.
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.
DeprecatedOptional<Hyperparameters> hyperparametersThe 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.
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.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters
are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Optional<List<Integration>> integrationsA list of integrations to enable for your fine-tuning job.
A list of integrations to enable for your fine-tuning job.
The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported.
Wandb wandbThe 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.
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.
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.
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.
Optional<Method> methodThe method used for fine-tuning.
The method used for fine-tuning.
Configuration for the DPO fine-tuning method.
Configuration for the DPO fine-tuning method.
The hyperparameters used for the DPO fine-tuning job.
The hyperparameters used for the DPO fine-tuning job.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Optional<Beta> betaThe beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.
The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.
Configuration for the reinforcement fine-tuning method.
Configuration for the reinforcement fine-tuning method.
Grader graderThe grader used for the fine-tuning job.
The grader used for the fine-tuning job.
class StringCheckGrader:A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
class TextSimilarityGrader:A TextSimilarityGrader object which grades text based on similarity metrics.
A TextSimilarityGrader object which grades text based on similarity metrics.
class ScoreModelGrader:A ScoreModelGrader object that uses a model to assign a score to the input.
A ScoreModelGrader object that uses a model to assign a score to the input.
List<Input> inputThe input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
Content contentInputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
List<EvalContentItem>
The object type, which is always score_model.
Optional<SamplingParams> samplingParamsThe sampling parameters for the model.
The sampling parameters for the model.
The maximum number of tokens the grader model may generate in its response.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1 defaults to none, which does not perform reasoning. The supported reasoning values for gpt-5.1 are none, low, medium, and high. Tool calls are supported for all reasoning values in gpt-5.1.
- All models before
gpt-5.1 default to medium reasoning effort, and do not support none.
- The
gpt-5-pro model defaults to (and only supports) high reasoning effort.
xhigh is supported for all models after gpt-5.1-codex-max.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1defaults tonone, which does not perform reasoning. The supported reasoning values forgpt-5.1arenone,low,medium, andhigh. Tool calls are supported for all reasoning values in gpt-5.1.- All models before
gpt-5.1default tomediumreasoning effort, and do not supportnone. - The
gpt-5-promodel defaults to (and only supports)highreasoning effort. xhighis supported for all models aftergpt-5.1-codex-max.
class MultiGrader:A MultiGrader object combines the output of multiple graders to produce a single score.
A MultiGrader object combines the output of multiple graders to produce a single score.
Graders gradersA StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
class StringCheckGrader:A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
class TextSimilarityGrader:A TextSimilarityGrader object which grades text based on similarity metrics.
A TextSimilarityGrader object which grades text based on similarity metrics.
class ScoreModelGrader:A ScoreModelGrader object that uses a model to assign a score to the input.
A ScoreModelGrader object that uses a model to assign a score to the input.
List<Input> inputThe input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
Content contentInputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
List<EvalContentItem>
The object type, which is always score_model.
Optional<SamplingParams> samplingParamsThe sampling parameters for the model.
The sampling parameters for the model.
The maximum number of tokens the grader model may generate in its response.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1 defaults to none, which does not perform reasoning. The supported reasoning values for gpt-5.1 are none, low, medium, and high. Tool calls are supported for all reasoning values in gpt-5.1.
- All models before
gpt-5.1 default to medium reasoning effort, and do not support none.
- The
gpt-5-pro model defaults to (and only supports) high reasoning effort.
xhigh is supported for all models after gpt-5.1-codex-max.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1defaults tonone, which does not perform reasoning. The supported reasoning values forgpt-5.1arenone,low,medium, andhigh. Tool calls are supported for all reasoning values in gpt-5.1.- All models before
gpt-5.1default tomediumreasoning effort, and do not supportnone. - The
gpt-5-promodel defaults to (and only supports)highreasoning effort. xhighis supported for all models aftergpt-5.1-codex-max.
class LabelModelGrader:A LabelModelGrader object which uses a model to assign labels to each item
in the evaluation.
A LabelModelGrader object which uses a model to assign labels to each item in the evaluation.
List<Input> input
Content contentInputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
List<EvalContentItem>
The hyperparameters used for the reinforcement fine-tuning job.
The hyperparameters used for the reinforcement fine-tuning job.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Optional<ComputeMultiplier> computeMultiplierMultiplier on amount of compute used for exploring search space during training.
Multiplier on amount of compute used for exploring search space during training.
Optional<LearningRateMultiplier> learningRateMultiplierScaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.
Configuration for the supervised fine-tuning method.
Configuration for the supervised fine-tuning method.
The hyperparameters used for the fine-tuning job.
The hyperparameters used for the fine-tuning job.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
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.
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.
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.
ReturnsExpand Collapse
class FineTuningJob:The fine_tuning.job object represents a fine-tuning job that has been created through the API.
The fine_tuning.job object represents a fine-tuning job that has been created through the API.
Optional<Error> errorFor fine-tuning jobs that have failed, this will contain more information on the cause of the failure.
For fine-tuning jobs that have failed, this will contain more information on the cause of the failure.
The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running.
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.
Hyperparameters hyperparametersThe hyperparameters used for the fine-tuning job. This value will only be returned when running supervised jobs.
The hyperparameters used for the fine-tuning job. This value will only be returned when running supervised jobs.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters
are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
The object type, which is always "fine_tuning.job".
The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the Files API.
Status statusThe current status of the fine-tuning job, which can be either validating_files, queued, running, succeeded, failed, or cancelled.
The current status of the fine-tuning job, which can be either validating_files, queued, running, succeeded, failed, or cancelled.
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.
The file ID used for training. You can retrieve the training data with the Files API.
The file ID used for validation. You can retrieve the validation results with the Files API.
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.
A list of integrations to enable for this fine-tuning job.
A list of integrations to enable for this fine-tuning job.
The type of the integration being enabled for the fine-tuning job
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.
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.
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.
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.
Optional<Method> methodThe method used for fine-tuning.
The method used for fine-tuning.
Configuration for the DPO fine-tuning method.
Configuration for the DPO fine-tuning method.
The hyperparameters used for the DPO fine-tuning job.
The hyperparameters used for the DPO fine-tuning job.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Optional<Beta> betaThe beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.
The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.
Configuration for the reinforcement fine-tuning method.
Configuration for the reinforcement fine-tuning method.
Grader graderThe grader used for the fine-tuning job.
The grader used for the fine-tuning job.
class StringCheckGrader:A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
class TextSimilarityGrader:A TextSimilarityGrader object which grades text based on similarity metrics.
A TextSimilarityGrader object which grades text based on similarity metrics.
class ScoreModelGrader:A ScoreModelGrader object that uses a model to assign a score to the input.
A ScoreModelGrader object that uses a model to assign a score to the input.
List<Input> inputThe input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
Content contentInputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
List<EvalContentItem>
The object type, which is always score_model.
Optional<SamplingParams> samplingParamsThe sampling parameters for the model.
The sampling parameters for the model.
The maximum number of tokens the grader model may generate in its response.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1 defaults to none, which does not perform reasoning. The supported reasoning values for gpt-5.1 are none, low, medium, and high. Tool calls are supported for all reasoning values in gpt-5.1.
- All models before
gpt-5.1 default to medium reasoning effort, and do not support none.
- The
gpt-5-pro model defaults to (and only supports) high reasoning effort.
xhigh is supported for all models after gpt-5.1-codex-max.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1defaults tonone, which does not perform reasoning. The supported reasoning values forgpt-5.1arenone,low,medium, andhigh. Tool calls are supported for all reasoning values in gpt-5.1.- All models before
gpt-5.1default tomediumreasoning effort, and do not supportnone. - The
gpt-5-promodel defaults to (and only supports)highreasoning effort. xhighis supported for all models aftergpt-5.1-codex-max.
class MultiGrader:A MultiGrader object combines the output of multiple graders to produce a single score.
A MultiGrader object combines the output of multiple graders to produce a single score.
Graders gradersA StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
class StringCheckGrader:A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
class TextSimilarityGrader:A TextSimilarityGrader object which grades text based on similarity metrics.
A TextSimilarityGrader object which grades text based on similarity metrics.
class ScoreModelGrader:A ScoreModelGrader object that uses a model to assign a score to the input.
A ScoreModelGrader object that uses a model to assign a score to the input.
List<Input> inputThe input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.
Content contentInputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
List<EvalContentItem>
The object type, which is always score_model.
Optional<SamplingParams> samplingParamsThe sampling parameters for the model.
The sampling parameters for the model.
The maximum number of tokens the grader model may generate in its response.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1 defaults to none, which does not perform reasoning. The supported reasoning values for gpt-5.1 are none, low, medium, and high. Tool calls are supported for all reasoning values in gpt-5.1.
- All models before
gpt-5.1 default to medium reasoning effort, and do not support none.
- The
gpt-5-pro model defaults to (and only supports) high reasoning effort.
xhigh is supported for all models after gpt-5.1-codex-max.
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1defaults tonone, which does not perform reasoning. The supported reasoning values forgpt-5.1arenone,low,medium, andhigh. Tool calls are supported for all reasoning values in gpt-5.1.- All models before
gpt-5.1default tomediumreasoning effort, and do not supportnone. - The
gpt-5-promodel defaults to (and only supports)highreasoning effort. xhighis supported for all models aftergpt-5.1-codex-max.
class LabelModelGrader:A LabelModelGrader object which uses a model to assign labels to each item
in the evaluation.
A LabelModelGrader object which uses a model to assign labels to each item in the evaluation.
List<Input> input
Content contentInputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
List<EvalContentItem>
The hyperparameters used for the reinforcement fine-tuning job.
The hyperparameters used for the reinforcement fine-tuning job.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Optional<ComputeMultiplier> computeMultiplierMultiplier on amount of compute used for exploring search space during training.
Multiplier on amount of compute used for exploring search space during training.
Optional<LearningRateMultiplier> learningRateMultiplierScaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.
Configuration for the supervised fine-tuning method.
Configuration for the supervised fine-tuning method.
The hyperparameters used for the fine-tuning job.
The hyperparameters used for the fine-tuning job.
Optional<BatchSize> batchSizeNumber of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.
Create fine-tuning job
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.finetuning.jobs.FineTuningJob;
import com.openai.models.finetuning.jobs.JobCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
JobCreateParams params = JobCreateParams.builder()
.model(JobCreateParams.Model.GPT_4O_MINI)
.trainingFile("file-abc123")
.build();
FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params);
}
}{
"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
}
Returns Examples
{
"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
}