Implementation:Openai Openai python Fine Tuning Jobs Create
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Fine_Tuning, Model_Training |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for creating fine-tuning jobs with configurable hyperparameters provided by the OpenAI Python SDK.
Description
The Jobs resource provides a create() method that submits fine-tuning jobs. It accepts a base model, training file ID, optional hyperparameters, validation data, and a custom suffix. The returned FineTuningJob object tracks the job's status and will contain the fine-tuned model name upon completion.
Usage
Call client.fine_tuning.jobs.create() with a model and training file ID.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/resources/fine_tuning/jobs/jobs.py
Signature
class Jobs(SyncAPIResource):
def create(
self,
*,
model: Union[str, ChatModel],
training_file: str,
hyperparameters: Hyperparameters | NotGiven = NOT_GIVEN,
validation_file: Optional[str] | NotGiven = NOT_GIVEN,
suffix: Optional[str] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
integrations: Optional[List[Integration]] | NotGiven = NOT_GIVEN,
method: Method | NotGiven = NOT_GIVEN,
) -> FineTuningJob:
"""
Creates a fine-tuning job.
Args:
model: Base model to fine-tune (e.g., "gpt-4o-mini-2024-07-18").
training_file: File ID of uploaded training data.
hyperparameters: Training hyperparameters (n_epochs, batch_size, learning_rate_multiplier).
validation_file: File ID of validation data.
suffix: Custom model name suffix (max 64 chars).
seed: Random seed for reproducibility.
"""
Import
from openai import OpenAI
# Access via client.fine_tuning.jobs.create()
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| model | Union[str, ChatModel] | Yes | Base model to fine-tune |
| training_file | str | Yes | File ID from upload step |
| hyperparameters | Hyperparameters | No | n_epochs, batch_size, learning_rate_multiplier |
| validation_file | str | No | Validation data file ID |
| suffix | str | No | Custom model name suffix (max 64 chars) |
| seed | int | No | Random seed for reproducibility |
Outputs
| Name | Type | Description |
|---|---|---|
| job | FineTuningJob | Job object with .id, .status, .fine_tuned_model |
Usage Examples
Basic Fine-tuning Job
from openai import OpenAI
client = OpenAI()
job = client.fine_tuning.jobs.create(
training_file="file-abc123",
model="gpt-4o-mini-2024-07-18",
)
print(f"Job ID: {job.id}")
print(f"Status: {job.status}")
With Hyperparameters
job = client.fine_tuning.jobs.create(
training_file="file-abc123",
model="gpt-4o-mini-2024-07-18",
validation_file="file-val456",
hyperparameters={
"n_epochs": 3,
"batch_size": 4,
"learning_rate_multiplier": 0.1,
},
suffix="my-classifier",
seed=42,
)
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment