Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Fine-tuning

Create a fine tuning job

POST /openai/v1/fine_tuning/jobs

Creates a fine tuning job from the supplied request.

Request Body

The request body.

Content-Type: application/json
model string | enum required

The name of the model to fine-tune. You can select one of the supported models.

Any of the following:
string
enum
babbage-002davinci-002gpt-3.5-turbogpt-4o-mini
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 OpenAI.CreateFineTuningJobRequestHyperparameters
batch_size enum | OpenAI.integer
One of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric
One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer
One of the following:
enum
auto
integer
suffix string | 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_file string | 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 OpenAI.CreateFineTuningJobRequestIntegrations[] | null

A list of integrations to enable for your fine-tuning job.

seed integer | 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 OpenAI.FineTuneMethod

The method used for fine-tuning.

type enum required

The type of method. Is either supervised, dpo, or reinforcement.

superviseddporeinforcement
supervised OpenAI.FineTuneSupervisedMethod

Configuration for the supervised fine-tuning method.

hyperparameters OpenAI.FineTuneSupervisedHyperparameters

The hyperparameters used for the fine-tuning job.

batch_size enum | OpenAI.integer

Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.

One of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric

Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.

One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer

The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.

One of the following:
enum
auto
integer
dpo OpenAI.FineTuneDPOMethod

Configuration for the DPO fine-tuning method.

hyperparameters OpenAI.FineTuneDPOHyperparameters

The hyperparameters used for the DPO fine-tuning job.

beta enum | OpenAI.numeric

The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.

One of the following:
enum
auto
number
batch_size enum | OpenAI.integer

Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.

One of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric

Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.

One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer

The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.

One of the following:
enum
auto
integer
reinforcement OpenAI.FineTuneReinforcementMethod

Configuration for the reinforcement fine-tuning method.

grader OpenAI.GraderStringCheck | OpenAI.GraderTextSimilarity | OpenAI.GraderPython | OpenAI.GraderScoreModel | OpenAI.GraderMulti required

The grader used for the fine-tuning job.

One of the following:
type enum required

The object type, which is always string_check.

string_check
name string required

The name of the grader.

input string required

The input text. This may include template strings.

reference string required

The reference text. This may include template strings.

operation enum required

The string check operation to perform. One of eq, ne, like, or ilike.

eqnelikeilike
type enum required

The type of grader.

text_similarity
name string required

The name of the grader.

input string required

The text being graded.

reference string required

The text being graded against.

evaluation_metric enum required

The evaluation metric to use. One of cosine, fuzzy_match, bleu, gleu, meteor, rouge_1, rouge_2, rouge_3, rouge_4, rouge_5, or rouge_l.

cosinefuzzy_matchbleugleumeteorrouge_1rouge_2rouge_3rouge_4rouge_5rouge_l
type enum required

The object type, which is always python.

python
name string required

The name of the grader.

source string required

The source code of the python script.

image_tag string

The image tag to use for the python script.

type enum required

The object type, which is always score_model.

score_model
name string required

The name of the grader.

model string required

The model to use for the evaluation.

sampling_params OpenAI.EvalGraderScoreModelSamplingParams
seed integer | null
top_p number | null
temperature number | null
max_completions_tokens integer | null
reasoning_effort string | enum | null

Constrains effort on reasoning for reasoning models. Currently supported values are none, minimal, low, medium, high, xhigh, and max. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Not all reasoning models support every value. See the reasoning guide for model-specific support.

Any of the following:
string
enum
noneminimallowmediumhighxhighmax
input OpenAI.EvalItem[] required

The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.

range OpenAI.numeric[]

The service requires two numbers for the score range. Defaults to [0, 1].

type enum required

The object type, which is always multi.

multi
name string required

The name of the grader.

graders object required
[key: string] OpenAI.GraderStringCheck | OpenAI.GraderTextSimilarity | OpenAI.GraderPython | OpenAI.GraderScoreModel | OpenAI.GraderLabelModel
Any of the following:
type enum required

The object type, which is always string_check.

string_check
name string required

The name of the grader.

input string required

The input text. This may include template strings.

reference string required

The reference text. This may include template strings.

operation enum required

The string check operation to perform. One of eq, ne, like, or ilike.

eqnelikeilike
type enum required

The type of grader.

text_similarity
name string required

The name of the grader.

input string required

The text being graded.

reference string required

The text being graded against.

evaluation_metric enum required

The evaluation metric to use. One of cosine, fuzzy_match, bleu, gleu, meteor, rouge_1, rouge_2, rouge_3, rouge_4, rouge_5, or rouge_l.

cosinefuzzy_matchbleugleumeteorrouge_1rouge_2rouge_3rouge_4rouge_5rouge_l
type enum required

The object type, which is always python.

python
name string required

The name of the grader.

source string required

The source code of the python script.

image_tag string

The image tag to use for the python script.

type enum required

The object type, which is always score_model.

score_model
name string required

The name of the grader.

model string required

The model to use for the evaluation.

sampling_params OpenAI.EvalGraderScoreModelSamplingParams
seed integer | null
top_p number | null
temperature number | null
max_completions_tokens integer | null
reasoning_effort string | enum | null

Constrains effort on reasoning for reasoning models. Currently supported values are none, minimal, low, medium, high, xhigh, and max. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Not all reasoning models support every value. See the reasoning guide for model-specific support.

Any of the following:
string
enum
noneminimallowmediumhighxhighmax
input OpenAI.EvalItem[] required

The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.

range OpenAI.numeric[]

The service requires two numbers for the score range. Defaults to [0, 1].

type enum required

The object type, which is always label_model.

label_model
name string required

The name of the grader.

model string required

The model to use for the evaluation. Must support structured outputs.

input OpenAI.EvalItem[] required
labels string[] required

The labels to assign to each item in the evaluation.

passing_labels string[] required

The labels that indicate a passing result. Must be a subset of labels.

calculate_output string required

A formula to calculate the output based on grader results.

hyperparameters OpenAI.FineTuneReinforcementHyperparameters

The hyperparameters used for the reinforcement fine-tuning job.

batch_size enum | OpenAI.integer

Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.

One of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric

Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.

One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer

The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.

One of the following:
enum
auto
integer
reasoning_effort enum

Level of reasoning effort.

defaultlowmediumhigh
compute_multiplier enum | OpenAI.numeric

Multiplier on amount of compute used for exploring search space during training.

One of the following:
enum
auto
number
eval_interval enum | OpenAI.integer

The number of training steps between evaluation runs.

One of the following:
enum
auto
integer
eval_samples enum | OpenAI.integer

Number of evaluation samples to generate per training step.

One of the following:
enum
auto
integer
metadata OpenAI.Metadata | 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.

[key: string] string

Responses

The request has succeeded.

Body

Content-Type: application/json
id string required

The object identifier, which can be referenced in the API endpoints.

created_at integer required

The Unix timestamp (in seconds) for when the fine-tuning job was created.

error OpenAI.FineTuningJobError | null required
fine_tuned_model string | null required
finished_at integer | null required
hyperparameters OpenAI.FineTuningJobHyperparameters | null

The hyperparameters used for the fine-tuning job. This value will only be returned when running supervised jobs.

batch_size enum | OpenAI.integer | null
Any of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric
One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer
One of the following:
enum
auto
integer
model string required

The base model that is being fine-tuned.

object enum required

The object type, which is always "fine_tuning.job".

fine_tuning.job
organization_id string required

The organization that owns the fine-tuning job.

result_files string[] required

The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the Files API.

status enum required

The current status of the fine-tuning job, which can be validating_files, queued, running, pausing, paused, succeeded, failed, or cancelled.

validating_filesqueuedrunningsucceededfailedcancelledpausingpaused
trained_tokens integer | null required
training_file string required

The file ID used for training. You can retrieve the training data with the Files API.

validation_file string | null required
integrations OpenAI.FineTuningIntegration[] | null
seed integer | null required

The seed used for the fine-tuning job.

estimated_finish integer | null
method OpenAI.FineTuneMethod | null

The method used for fine-tuning.

type enum required

The type of method. Is either supervised, dpo, or reinforcement.

superviseddporeinforcement
supervised OpenAI.FineTuneSupervisedMethod

Configuration for the supervised fine-tuning method.

hyperparameters OpenAI.FineTuneSupervisedHyperparameters

The hyperparameters used for the fine-tuning job.

batch_size enum | OpenAI.integer

Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.

One of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric

Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.

One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer

The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.

One of the following:
enum
auto
integer
dpo OpenAI.FineTuneDPOMethod

Configuration for the DPO fine-tuning method.

hyperparameters OpenAI.FineTuneDPOHyperparameters

The hyperparameters used for the DPO fine-tuning job.

beta enum | OpenAI.numeric

The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.

One of the following:
enum
auto
number
batch_size enum | OpenAI.integer

Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.

One of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric

Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.

One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer

The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.

One of the following:
enum
auto
integer
reinforcement OpenAI.FineTuneReinforcementMethod

Configuration for the reinforcement fine-tuning method.

grader OpenAI.GraderStringCheck | OpenAI.GraderTextSimilarity | OpenAI.GraderPython | OpenAI.GraderScoreModel | OpenAI.GraderMulti required

The grader used for the fine-tuning job.

One of the following:
type enum required

The object type, which is always string_check.

string_check
name string required

The name of the grader.

input string required

The input text. This may include template strings.

reference string required

The reference text. This may include template strings.

operation enum required

The string check operation to perform. One of eq, ne, like, or ilike.

eqnelikeilike
type enum required

The type of grader.

text_similarity
name string required

The name of the grader.

input string required

The text being graded.

reference string required

The text being graded against.

evaluation_metric enum required

The evaluation metric to use. One of cosine, fuzzy_match, bleu, gleu, meteor, rouge_1, rouge_2, rouge_3, rouge_4, rouge_5, or rouge_l.

cosinefuzzy_matchbleugleumeteorrouge_1rouge_2rouge_3rouge_4rouge_5rouge_l
type enum required

The object type, which is always python.

python
name string required

The name of the grader.

source string required

The source code of the python script.

image_tag string

The image tag to use for the python script.

type enum required

The object type, which is always score_model.

score_model
name string required

The name of the grader.

model string required

The model to use for the evaluation.

sampling_params OpenAI.EvalGraderScoreModelSamplingParams
seed integer | null
top_p number | null
temperature number | null
max_completions_tokens integer | null
reasoning_effort string | enum | null

Constrains effort on reasoning for reasoning models. Currently supported values are none, minimal, low, medium, high, xhigh, and max. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Not all reasoning models support every value. See the reasoning guide for model-specific support.

Any of the following:
string
enum
noneminimallowmediumhighxhighmax
input OpenAI.EvalItem[] required

The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.

range OpenAI.numeric[]

The service requires two numbers for the score range. Defaults to [0, 1].

type enum required

The object type, which is always multi.

multi
name string required

The name of the grader.

graders object required
[key: string] OpenAI.GraderStringCheck | OpenAI.GraderTextSimilarity | OpenAI.GraderPython | OpenAI.GraderScoreModel | OpenAI.GraderLabelModel
Any of the following:
type enum required

The object type, which is always string_check.

string_check
name string required

The name of the grader.

input string required

The input text. This may include template strings.

reference string required

The reference text. This may include template strings.

operation enum required

The string check operation to perform. One of eq, ne, like, or ilike.

eqnelikeilike
type enum required

The type of grader.

text_similarity
name string required

The name of the grader.

input string required

The text being graded.

reference string required

The text being graded against.

evaluation_metric enum required

The evaluation metric to use. One of cosine, fuzzy_match, bleu, gleu, meteor, rouge_1, rouge_2, rouge_3, rouge_4, rouge_5, or rouge_l.

cosinefuzzy_matchbleugleumeteorrouge_1rouge_2rouge_3rouge_4rouge_5rouge_l
type enum required

The object type, which is always python.

python
name string required

The name of the grader.

source string required

The source code of the python script.

image_tag string

The image tag to use for the python script.

type enum required

The object type, which is always score_model.

score_model
name string required

The name of the grader.

model string required

The model to use for the evaluation.

sampling_params OpenAI.EvalGraderScoreModelSamplingParams
seed integer | null
top_p number | null
temperature number | null
max_completions_tokens integer | null
reasoning_effort string | enum | null

Constrains effort on reasoning for reasoning models. Currently supported values are none, minimal, low, medium, high, xhigh, and max. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. Not all reasoning models support every value. See the reasoning guide for model-specific support.

Any of the following:
string
enum
noneminimallowmediumhighxhighmax
input OpenAI.EvalItem[] required

The input messages evaluated by the grader. Supports text, output text, input image, and input audio content blocks, and may include template strings.

range OpenAI.numeric[]

The service requires two numbers for the score range. Defaults to [0, 1].

type enum required

The object type, which is always label_model.

label_model
name string required

The name of the grader.

model string required

The model to use for the evaluation. Must support structured outputs.

input OpenAI.EvalItem[] required
labels string[] required

The labels to assign to each item in the evaluation.

passing_labels string[] required

The labels that indicate a passing result. Must be a subset of labels.

calculate_output string required

A formula to calculate the output based on grader results.

hyperparameters OpenAI.FineTuneReinforcementHyperparameters

The hyperparameters used for the reinforcement fine-tuning job.

batch_size enum | OpenAI.integer

Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.

One of the following:
enum
auto
integer
learning_rate_multiplier enum | OpenAI.numeric

Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.

One of the following:
enum
auto
number
n_epochs enum | OpenAI.integer

The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.

One of the following:
enum
auto
integer
reasoning_effort enum

Level of reasoning effort.

defaultlowmediumhigh
compute_multiplier enum | OpenAI.numeric

Multiplier on amount of compute used for exploring search space during training.

One of the following:
enum
auto
number
eval_interval enum | OpenAI.integer

The number of training steps between evaluation runs.

One of the following:
enum
auto
integer
eval_samples enum | OpenAI.integer

Number of evaluation samples to generate per training step.

One of the following:
enum
auto
integer
metadata OpenAI.Metadata | 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.

[key: string] string

Client error

Body

Content-Type: application/json
error OpenAI.Error required
code string | null required
message string required
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Any of the following:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string required

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Body

Content-Type: application/json
error OpenAI.Error required
code string | null required
message string required
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Any of the following:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string required

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

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"
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
fine_tuning_job = client.fine_tuning.jobs.create(
    model="gpt-4o-mini",
    training_file="file-abc123",
)
print(fine_tuning_job.id)
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const fineTune = await openai.fineTuning.jobs.create({
    training_file: "file-abc123"
  });

  console.log(fineTune);
}

main();
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const fineTuningJob = await client.fineTuning.jobs.create({
  model: 'gpt-4o-mini',
  training_file: 'file-abc123',
});

console.log(fineTuningJob.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    fineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
        Model:        openai.FineTuningJobNewParamsModelGPT4oMini,
        TrainingFile: "file-abc123",
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", fineTuningJob.ID)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

fine_tuning_job = openai.fine_tuning.jobs.create(model: :"gpt-4o-mini", training_file: "file-abc123")

puts(fine_tuning_job)

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
}

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-abc123",
    "model": "gpt-4o-mini",
    "method": {
      "type": "supervised",
      "supervised": {
        "hyperparameters": {
          "n_epochs": 2
        }
      }
    }
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
fine_tuning_job = client.fine_tuning.jobs.create(
    model="gpt-4o-mini",
    training_file="file-abc123",
)
print(fine_tuning_job.id)
import OpenAI from "openai";
import { SupervisedMethod, SupervisedHyperparameters } from "openai/resources/fine-tuning/methods";

const openai = new OpenAI();

async function main() {
  const fineTune = await openai.fineTuning.jobs.create({
    training_file: "file-abc123",
    model: "gpt-4o-mini",
    method: {
      type: "supervised",
      supervised: {
        hyperparameters: {
          n_epochs: 2
        }
      }
    }
  });

  console.log(fineTune);
}

main();
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const fineTuningJob = await client.fineTuning.jobs.create({
  model: 'gpt-4o-mini',
  training_file: 'file-abc123',
});

console.log(fineTuningJob.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    fineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
        Model:        openai.FineTuningJobNewParamsModelGPT4oMini,
        TrainingFile: "file-abc123",
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", fineTuningJob.ID)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

fine_tuning_job = openai.fine_tuning.jobs.create(model: :"gpt-4o-mini", training_file: "file-abc123")

puts(fine_tuning_job)

Response

{
  "object": "fine_tuning.job",
  "id": "ftjob-abc123",
  "model": "gpt-4o-mini",
  "created_at": 1721764800,
  "fine_tuned_model": null,
  "organization_id": "org-123",
  "result_files": [],
  "status": "queued",
  "validation_file": null,
  "training_file": "file-abc123",
  "hyperparameters": {
    "batch_size": "auto",
    "learning_rate_multiplier": "auto",
    "n_epochs": 2
  },
  "method": {
    "type": "supervised",
    "supervised": {
      "hyperparameters": {
        "batch_size": "auto",
        "learning_rate_multiplier": "auto",
        "n_epochs": 2
      }
    }
  },
  "metadata": null,
  "error": {
    "code": null,
    "message": null,
    "param": null
  },
  "finished_at": null,
  "seed": 683058546,
  "trained_tokens": null,
  "estimated_finish": null,
  "integrations": [],
  "user_provided_suffix": null,
  "usage_metrics": null,
  "shared_with_openai": false
}

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-abc123",
    "validation_file": "file-abc123",
    "model": "gpt-4o-mini",
    "method": {
      "type": "dpo",
      "dpo": {
        "hyperparameters": {
          "beta": 0.1
        }
      }
    }
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
fine_tuning_job = client.fine_tuning.jobs.create(
    model="gpt-4o-mini",
    training_file="file-abc123",
)
print(fine_tuning_job.id)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const fineTuningJob = await client.fineTuning.jobs.create({
  model: 'gpt-4o-mini',
  training_file: 'file-abc123',
});

console.log(fineTuningJob.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    fineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
        Model:        openai.FineTuningJobNewParamsModelGPT4oMini,
        TrainingFile: "file-abc123",
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", fineTuningJob.ID)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

fine_tuning_job = openai.fine_tuning.jobs.create(model: :"gpt-4o-mini", training_file: "file-abc123")

puts(fine_tuning_job)

Response

{
  "object": "fine_tuning.job",
  "id": "ftjob-abc",
  "model": "gpt-4o-mini",
  "created_at": 1746130590,
  "fine_tuned_model": null,
  "organization_id": "org-abc",
  "result_files": [],
  "status": "queued",
  "validation_file": "file-123",
  "training_file": "file-abc",
  "method": {
    "type": "dpo",
    "dpo": {
      "hyperparameters": {
        "beta": 0.1,
        "batch_size": "auto",
        "learning_rate_multiplier": "auto",
        "n_epochs": "auto"
      }
    }
  },
  "metadata": null,
  "error": {
    "code": null,
    "message": null,
    "param": null
  },
  "finished_at": null,
  "hyperparameters": null,
  "seed": 1036326793,
  "estimated_finish": null,
  "integrations": [],
  "user_provided_suffix": null,
  "usage_metrics": null,
  "shared_with_openai": false
}

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-abc",
    "validation_file": "file-123",
    "model": "o4-mini",
    "method": {
      "type": "reinforcement",
      "reinforcement": {
        "grader": {
          "type": "string_check",
          "name": "Example string check grader",
          "input": "{{sample.output_text}}",
          "reference": "{{item.label}}",
          "operation": "eq"
        },
        "hyperparameters": {
          "reasoning_effort": "medium"
        }
      }
    }
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
fine_tuning_job = client.fine_tuning.jobs.create(
    model="gpt-4o-mini",
    training_file="file-abc123",
)
print(fine_tuning_job.id)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const fineTuningJob = await client.fineTuning.jobs.create({
  model: 'gpt-4o-mini',
  training_file: 'file-abc123',
});

console.log(fineTuningJob.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    fineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
        Model:        openai.FineTuningJobNewParamsModelGPT4oMini,
        TrainingFile: "file-abc123",
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", fineTuningJob.ID)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

fine_tuning_job = openai.fine_tuning.jobs.create(model: :"gpt-4o-mini", training_file: "file-abc123")

puts(fine_tuning_job)

Response

{
  "object": "fine_tuning.job",
  "id": "ftjob-abc123",
  "model": "o4-mini",
  "created_at": 1721764800,
  "finished_at": null,
  "fine_tuned_model": null,
  "organization_id": "org-123",
  "result_files": [],
  "status": "validating_files",
  "validation_file": "file-123",
  "training_file": "file-abc",
  "trained_tokens": null,
  "error": {},
  "user_provided_suffix": null,
  "seed": 950189191,
  "estimated_finish": null,
  "integrations": [],
  "method": {
    "type": "reinforcement",
    "reinforcement": {
      "hyperparameters": {
        "batch_size": "auto",
        "learning_rate_multiplier": "auto",
        "n_epochs": "auto",
        "eval_interval": "auto",
        "eval_samples": "auto",
        "compute_multiplier": "auto",
        "reasoning_effort": "medium"
      },
      "grader": {
        "type": "string_check",
        "name": "Example string check grader",
        "input": "{{sample.output_text}}",
        "reference": "{{item.label}}",
        "operation": "eq"
      },
      "response_format": null
    }
  },
  "metadata": null,
  "usage_metrics": null,
  "shared_with_openai": false
}

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-abc123",
    "validation_file": "file-abc123",
    "model": "gpt-4o-mini"
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
fine_tuning_job = client.fine_tuning.jobs.create(
    model="gpt-4o-mini",
    training_file="file-abc123",
)
print(fine_tuning_job.id)
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const fineTune = await openai.fineTuning.jobs.create({
    training_file: "file-abc123",
    validation_file: "file-abc123"
  });

  console.log(fineTune);
}

main();
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const fineTuningJob = await client.fineTuning.jobs.create({
  model: 'gpt-4o-mini',
  training_file: 'file-abc123',
});

console.log(fineTuningJob.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    fineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
        Model:        openai.FineTuningJobNewParamsModelGPT4oMini,
        TrainingFile: "file-abc123",
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", fineTuningJob.ID)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

fine_tuning_job = openai.fine_tuning.jobs.create(model: :"gpt-4o-mini", training_file: "file-abc123")

puts(fine_tuning_job)

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": "file-abc123",
  "training_file": "file-abc123",
  "method": {
    "type": "supervised",
    "supervised": {
      "hyperparameters": {
        "batch_size": "auto",
        "learning_rate_multiplier": "auto",
        "n_epochs": "auto",
      }
    }
  },
  "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-abc123",
    "validation_file": "file-abc123",
    "model": "gpt-4o-mini",
    "integrations": [
      {
        "type": "wandb",
        "wandb": {
          "project": "my-wandb-project",
          "name": "ft-run-display-name"
          "tags": [
            "first-experiment", "v2"
          ]
        }
      }
    ]
  }'
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const fineTuningJob = await client.fineTuning.jobs.create({
  model: 'gpt-4o-mini',
  training_file: 'file-abc123',
});

console.log(fineTuningJob.id);
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
fine_tuning_job = client.fine_tuning.jobs.create(
    model="gpt-4o-mini",
    training_file="file-abc123",
)
print(fine_tuning_job.id)
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    fineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
        Model:        openai.FineTuningJobNewParamsModelGPT4oMini,
        TrainingFile: "file-abc123",
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", fineTuningJob.ID)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

fine_tuning_job = openai.fine_tuning.jobs.create(model: :"gpt-4o-mini", training_file: "file-abc123")

puts(fine_tuning_job)

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": "file-abc123",
  "training_file": "file-abc123",
  "integrations": [
    {
      "type": "wandb",
      "wandb": {
        "project": "my-wandb-project",
        "entity": None,
        "run_id": "ftjob-abc123"
      }
    }
  ],
  "method": {
    "type": "supervised",
    "supervised": {
      "hyperparameters": {
        "batch_size": "auto",
        "learning_rate_multiplier": "auto",
        "n_epochs": "auto",
      }
    }
  },
  "metadata": null
}
en-us
Your Privacy Choices
  • AI Disclaimer
  • Previous Versions
  • Blog
  • Contribute
  • Privacy
  • Consumer Health Privacy
  • Terms of Use
  • Trademarks
  • © Microsoft 2026