Skip to content

jobs

The jobs module provides synchronous and asynchronous access to fine-tuning job resources and enables you to create, retrieve, list, and cancel fine-tuning jobs and list the events associated with them.

Fine-tuning jobs allow you to customize pre-trained models with your own datasets, optimizing performance for specific tasks or improving understanding of particular data types. The classes in the jobs module includes methods for managing fine-tuning jobs, like creating a new job, fetching details of an existing job, listing all jobs, canceling a job, and listing events associated with a job.

Classes:

Name Description
AsyncJobs
AsyncJobsWithRawResponse
AsyncJobsWithStreamingResponse
Jobs
JobsWithRawResponse
JobsWithStreamingResponse

AsyncJobs

AsyncJobs(client: AsyncOpenAI)

Methods:

Name Description
cancel

Immediately cancel a fine-tune job.

create

Creates a fine-tuning job which begins the process of creating a new model from

list

List your organization's fine-tuning jobs

list_events

Get status updates for a fine-tuning job.

retrieve

Get info about a fine-tuning job.

with_raw_response
with_streaming_response

cancel async

cancel(
    fine_tuning_job_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob

Immediately cancel a fine-tune job.

Parameters:

Name Type Description Default
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

create async

create(
    *,
    model: Union[
        str,
        Literal[
            "babbage-002", "davinci-002", "gpt-3.5-turbo"
        ],
    ],
    training_file: str,
    hyperparameters: Hyperparameters | NotGiven = NOT_GIVEN,
    suffix: Optional[str] | NotGiven = NOT_GIVEN,
    validation_file: Optional[str] | NotGiven = NOT_GIVEN,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob

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.

Learn more about fine-tuning

Parameters:

Name Type Description Default
model Union[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]

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

required
training_file str

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.

See the fine-tuning guide for more details.

required
hyperparameters Hyperparameters | NotGiven

The hyperparameters used for the fine-tuning job.

NOT_GIVEN
suffix Optional[str] | NotGiven

A string of up to 18 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-3.5-turbo:openai:custom-model-name:7p4lURel.

NOT_GIVEN
validation_file Optional[str] | NotGiven

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.

NOT_GIVEN
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

list

list(
    *,
    after: str | NotGiven = NOT_GIVEN,
    limit: int | NotGiven = NOT_GIVEN,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncPaginator[
    FineTuningJob, AsyncCursorPage[FineTuningJob]
]

List your organization's fine-tuning jobs

Parameters:

Name Type Description Default
after str | NotGiven

Identifier for the last job from the previous pagination request.

NOT_GIVEN
limit int | NotGiven

Number of fine-tuning jobs to retrieve.

NOT_GIVEN
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

list_events

list_events(
    fine_tuning_job_id: str,
    *,
    after: str | NotGiven = NOT_GIVEN,
    limit: int | NotGiven = NOT_GIVEN,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncPaginator[
    FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]
]

Get status updates for a fine-tuning job.

Parameters:

Name Type Description Default
after str | NotGiven

Identifier for the last event from the previous pagination request.

NOT_GIVEN
limit int | NotGiven

Number of events to retrieve.

NOT_GIVEN
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

retrieve async

retrieve(
    fine_tuning_job_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob

Get info about a fine-tuning job.

Learn more about fine-tuning

Parameters:

Name Type Description Default
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

with_raw_response

with_raw_response() -> AsyncJobsWithRawResponse

with_streaming_response

with_streaming_response() -> AsyncJobsWithStreamingResponse

AsyncJobsWithRawResponse

AsyncJobsWithRawResponse(jobs: AsyncJobs)

Attributes:

Name Type Description
cancel
create
list
list_events
retrieve

cancel instance-attribute

cancel = async_to_raw_response_wrapper(cancel)

create instance-attribute

create = async_to_raw_response_wrapper(create)

list instance-attribute

list = async_to_raw_response_wrapper(list)

list_events instance-attribute

list_events = async_to_raw_response_wrapper(list_events)

retrieve instance-attribute

retrieve = async_to_raw_response_wrapper(retrieve)

AsyncJobsWithStreamingResponse

AsyncJobsWithStreamingResponse(jobs: AsyncJobs)

Attributes:

Name Type Description
cancel
create
list
list_events
retrieve

cancel instance-attribute

cancel = async_to_streamed_response_wrapper(cancel)

create instance-attribute

create = async_to_streamed_response_wrapper(create)

list instance-attribute

list = async_to_streamed_response_wrapper(list)

list_events instance-attribute

list_events = async_to_streamed_response_wrapper(
    list_events
)

retrieve instance-attribute

retrieve = async_to_streamed_response_wrapper(retrieve)

Jobs

Jobs(client: OpenAI)

Methods:

Name Description
cancel

Immediately cancel a fine-tune job.

create

Creates a fine-tuning job which begins the process of creating a new model from

list

List your organization's fine-tuning jobs

list_events

Get status updates for a fine-tuning job.

retrieve

Get info about a fine-tuning job.

with_raw_response
with_streaming_response

cancel

cancel(
    fine_tuning_job_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob

Immediately cancel a fine-tune job.

Parameters:

Name Type Description Default
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

create

create(
    *,
    model: Union[
        str,
        Literal[
            "babbage-002", "davinci-002", "gpt-3.5-turbo"
        ],
    ],
    training_file: str,
    hyperparameters: Hyperparameters | NotGiven = NOT_GIVEN,
    suffix: Optional[str] | NotGiven = NOT_GIVEN,
    validation_file: Optional[str] | NotGiven = NOT_GIVEN,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob

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.

Learn more about fine-tuning

Parameters:

Name Type Description Default
model Union[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]

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

required
training_file str

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.

See the fine-tuning guide for more details.

required
hyperparameters Hyperparameters | NotGiven

The hyperparameters used for the fine-tuning job.

NOT_GIVEN
suffix Optional[str] | NotGiven

A string of up to 18 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-3.5-turbo:openai:custom-model-name:7p4lURel.

NOT_GIVEN
validation_file Optional[str] | NotGiven

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.

NOT_GIVEN
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

list

list(
    *,
    after: str | NotGiven = NOT_GIVEN,
    limit: int | NotGiven = NOT_GIVEN,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> SyncCursorPage[FineTuningJob]

List your organization's fine-tuning jobs

Parameters:

Name Type Description Default
after str | NotGiven

Identifier for the last job from the previous pagination request.

NOT_GIVEN
limit int | NotGiven

Number of fine-tuning jobs to retrieve.

NOT_GIVEN
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

list_events

list_events(
    fine_tuning_job_id: str,
    *,
    after: str | NotGiven = NOT_GIVEN,
    limit: int | NotGiven = NOT_GIVEN,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> SyncCursorPage[FineTuningJobEvent]

Get status updates for a fine-tuning job.

Parameters:

Name Type Description Default
after str | NotGiven

Identifier for the last event from the previous pagination request.

NOT_GIVEN
limit int | NotGiven

Number of events to retrieve.

NOT_GIVEN
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

retrieve

retrieve(
    fine_tuning_job_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob

Get info about a fine-tuning job.

Learn more about fine-tuning

Parameters:

Name Type Description Default
extra_headers Headers | None

Send extra headers

None
extra_query Query | None

Add additional query parameters to the request

None
extra_body Body | None

Add additional JSON properties to the request

None
timeout float | Timeout | None | NotGiven

Override the client-level default timeout for this request, in seconds

NOT_GIVEN

with_raw_response

with_raw_response() -> JobsWithRawResponse

with_streaming_response

with_streaming_response() -> JobsWithStreamingResponse

JobsWithRawResponse

JobsWithRawResponse(jobs: Jobs)

Attributes:

Name Type Description
cancel
create
list
list_events
retrieve

cancel instance-attribute

cancel = to_raw_response_wrapper(cancel)

create instance-attribute

create = to_raw_response_wrapper(create)

list instance-attribute

list = to_raw_response_wrapper(list)

list_events instance-attribute

list_events = to_raw_response_wrapper(list_events)

retrieve instance-attribute

retrieve = to_raw_response_wrapper(retrieve)

JobsWithStreamingResponse

JobsWithStreamingResponse(jobs: Jobs)

Attributes:

Name Type Description
cancel
create
list
list_events
retrieve

cancel instance-attribute

cancel = to_streamed_response_wrapper(cancel)

create instance-attribute

create = to_streamed_response_wrapper(create)

list instance-attribute

list = to_streamed_response_wrapper(list)

list_events instance-attribute

list_events = to_streamed_response_wrapper(list_events)

retrieve instance-attribute

retrieve = to_streamed_response_wrapper(retrieve)