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.
Body ParametersJSON
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.
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.
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.
Returns
Create fine-tuning job
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"
}'
{
"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
}
Create fine-tuning job
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
}
}
}
}'
{
"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
}
Create fine-tuning job
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
}
}
}
}'
{
"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
}
Create fine-tuning job
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"
}
}
}
}'
{
"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
}
Create fine-tuning job
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"
}'
{
"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
}
Create fine-tuning job
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"
]
}
}
]
}'
{
"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
}
Returns Examples
{
"id": "id",
"created_at": 0,
"error": {
"code": "code",
"message": "message",
"param": "param"
},
"fine_tuned_model": "fine_tuned_model",
"finished_at": 0,
"hyperparameters": {
"batch_size": "auto",
"learning_rate_multiplier": "auto",
"n_epochs": "auto"
},
"model": "model",
"object": "fine_tuning.job",
"organization_id": "organization_id",
"result_files": [
"file-abc123"
],
"seed": 0,
"status": "validating_files",
"trained_tokens": 0,
"training_file": "training_file",
"validation_file": "validation_file",
"estimated_finish": 0,
"integrations": [
{
"type": "wandb",
"wandb": {
"project": "my-wandb-project",
"entity": "entity",
"name": "name",
"tags": [
"custom-tag"
]
}
}
],
"metadata": {
"foo": "string"
},
"method": {
"type": "supervised",
"dpo": {
"hyperparameters": {
"batch_size": "auto",
"beta": "auto",
"learning_rate_multiplier": "auto",
"n_epochs": "auto"
}
},
"reinforcement": {
"grader": {
"input": "input",
"name": "name",
"operation": "eq",
"reference": "reference",
"type": "string_check"
},
"hyperparameters": {
"batch_size": "auto",
"compute_multiplier": "auto",
"eval_interval": "auto",
"eval_samples": "auto",
"learning_rate_multiplier": "auto",
"n_epochs": "auto",
"reasoning_effort": "default"
}
},
"supervised": {
"hyperparameters": {
"batch_size": "auto",
"learning_rate_multiplier": "auto",
"n_epochs": "auto"
}
}
}
}