openapi: 3.0.0 info: title: 'OpenAI fine tuning' description: Needs description. version: 2.0.0 termsOfService: https://openai.com/policies/terms-of-use contact: name: OpenAI Support url: https://help.openai.com/ license: name: MIT url: https://github.com/openai/openai-openapi/blob/master/LICENSE servers: - url: https://api.openai.com/v1 tags: - name: Fine Tuning paths: /fine_tuning/jobs: post: operationId: createFineTuningJob tags: - Fine Tuning summary: >- OpenAI 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](/docs/guides/fine-tuning) requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateFineTuningJobRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/FineTuningJob' x-oaiMeta: name: Create fine-tuning job group: fine-tuning returns: A [fine-tuning.job](/docs/api-reference/fine-tuning/object) object. examples: - title: Default request: curl: | 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-3.5-turbo" }' python: | from openai import OpenAI client = OpenAI() client.fine_tuning.jobs.create( training_file="file-abc123", model="gpt-3.5-turbo" ) node.js: | 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(); response: | { "object": "fine_tuning.job", "id": "ftjob-abc123", "model": "gpt-3.5-turbo-0613", "created_at": 1614807352, "fine_tuned_model": null, "organization_id": "org-123", "result_files": [], "status": "queued", "validation_file": null, "training_file": "file-abc123", } - title: Epochs request: curl: | 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-3.5-turbo", "hyperparameters": { "n_epochs": 2 } }' python: | from openai import OpenAI client = OpenAI() client.fine_tuning.jobs.create( training_file="file-abc123", model="gpt-3.5-turbo", hyperparameters={ "n_epochs":2 } ) node.js: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { const fineTune = await openai.fineTuning.jobs.create({ training_file: "file-abc123", model: "gpt-3.5-turbo", hyperparameters: { n_epochs: 2 } }); console.log(fineTune); } main(); response: | { "object": "fine_tuning.job", "id": "ftjob-abc123", "model": "gpt-3.5-turbo-0613", "created_at": 1614807352, "fine_tuned_model": null, "organization_id": "org-123", "result_files": [], "status": "queued", "validation_file": null, "training_file": "file-abc123", "hyperparameters": {"n_epochs": 2}, } - title: Validation file request: curl: | 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-3.5-turbo" }' python: | from openai import OpenAI client = OpenAI() client.fine_tuning.jobs.create( training_file="file-abc123", validation_file="file-def456", model="gpt-3.5-turbo" ) node.js: | 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(); response: | { "object": "fine_tuning.job", "id": "ftjob-abc123", "model": "gpt-3.5-turbo-0613", "created_at": 1614807352, "fine_tuned_model": null, "organization_id": "org-123", "result_files": [], "status": "queued", "validation_file": "file-abc123", "training_file": "file-abc123", } get: operationId: listPaginatedFineTuningJobs tags: - Fine Tuning summary: |- OpenAI List your organization's fine-tuning jobs parameters: - name: after in: query description: Identifier for the last job from the previous pagination request. required: false schema: type: string - name: limit in: query description: Number of fine-tuning jobs to retrieve. required: false schema: type: integer default: 20 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ListPaginatedFineTuningJobsResponse' x-oaiMeta: name: List fine-tuning jobs group: fine-tuning returns: >- A list of paginated [fine-tuning job](/docs/api-reference/fine-tuning/object) objects. examples: request: curl: | curl https://api.openai.com/v1/fine_tuning/jobs?limit=2 \ -H "Authorization: Bearer $OPENAI_API_KEY" python: | from openai import OpenAI client = OpenAI() client.fine_tuning.jobs.list() node.js: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { const list = await openai.fineTuning.jobs.list(); for await (const fineTune of list) { console.log(fineTune); } } main(); response: | { "object": "list", "data": [ { "object": "fine_tuning.job.event", "id": "ft-event-TjX0lMfOniCZX64t9PUQT5hn", "created_at": 1689813489, "level": "warn", "message": "Fine tuning process stopping due to job cancellation", "data": null, "type": "message" }, { ... }, { ... } ], "has_more": true } /fine_tuning/jobs/{fine_tuning_job_id}: get: operationId: retrieveFineTuningJob tags: - Fine Tuning summary: |- OpenAI Get info about a fine-tuning job. [Learn more about fine-tuning](/docs/guides/fine-tuning) parameters: - in: path name: fine_tuning_job_id required: true schema: type: string example: ft-AF1WoRqd3aJAHsqc9NY7iL8F description: | The ID of the fine-tuning job. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/FineTuningJob' x-oaiMeta: name: Retrieve fine-tuning job group: fine-tuning returns: >- The [fine-tuning](/docs/api-reference/fine-tuning/object) object with the given ID. examples: request: curl: > curl https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ -H "Authorization: Bearer $OPENAI_API_KEY" python: | from openai import OpenAI client = OpenAI() client.fine_tuning.jobs.retrieve("ftjob-abc123") node.js: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { const fineTune = await openai.fineTuning.jobs.retrieve("ftjob-abc123"); console.log(fineTune); } main(); response: | { "object": "fine_tuning.job", "id": "ftjob-abc123", "model": "davinci-002", "created_at": 1692661014, "finished_at": 1692661190, "fine_tuned_model": "ft:davinci-002:my-org:custom_suffix:7q8mpxmy", "organization_id": "org-123", "result_files": [ "file-abc123" ], "status": "succeeded", "validation_file": null, "training_file": "file-abc123", "hyperparameters": { "n_epochs": 4, }, "trained_tokens": 5768 } /fine_tuning/jobs/{fine_tuning_job_id}/events: get: operationId: listFineTuningEvents tags: - Fine Tuning summary: |- OpenAI Get status updates for a fine-tuning job. parameters: - in: path name: fine_tuning_job_id required: true schema: type: string example: ft-AF1WoRqd3aJAHsqc9NY7iL8F description: | The ID of the fine-tuning job to get events for. - name: after in: query description: Identifier for the last event from the previous pagination request. required: false schema: type: string - name: limit in: query description: Number of events to retrieve. required: false schema: type: integer default: 20 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ListFineTuningJobEventsResponse' x-oaiMeta: name: List fine-tuning events group: fine-tuning returns: A list of fine-tuning event objects. examples: request: curl: > curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/events \ -H "Authorization: Bearer $OPENAI_API_KEY" python: | from openai import OpenAI client = OpenAI() client.fine_tuning.jobs.list_events( fine_tuning_job_id="ftjob-abc123", limit=2 ) node.js: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { const list = await openai.fineTuning.list_events(id="ftjob-abc123", limit=2); for await (const fineTune of list) { console.log(fineTune); } } main(); response: | { "object": "list", "data": [ { "object": "fine_tuning.job.event", "id": "ft-event-ddTJfwuMVpfLXseO0Am0Gqjm", "created_at": 1692407401, "level": "info", "message": "Fine tuning job successfully completed", "data": null, "type": "message" }, { "object": "fine_tuning.job.event", "id": "ft-event-tyiGuB72evQncpH87xe505Sv", "created_at": 1692407400, "level": "info", "message": "New fine-tuned model created: ft:gpt-3.5-turbo:openai::7p4lURel", "data": null, "type": "message" } ], "has_more": true } /fine_tuning/jobs/{fine_tuning_job_id}/cancel: post: operationId: cancelFineTuningJob tags: - Fine Tuning summary: |- OpenAI Immediately cancel a fine-tune job. parameters: - in: path name: fine_tuning_job_id required: true schema: type: string example: ft-AF1WoRqd3aJAHsqc9NY7iL8F description: | The ID of the fine-tuning job to cancel. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/FineTuningJob' x-oaiMeta: name: Cancel fine-tuning group: fine-tuning returns: >- The cancelled [fine-tuning](/docs/api-reference/fine-tuning/object) object. examples: request: curl: > curl -X POST https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/cancel \ -H "Authorization: Bearer $OPENAI_API_KEY" python: | from openai import OpenAI client = OpenAI() client.fine_tuning.jobs.cancel("ftjob-abc123") node.js: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { const fineTune = await openai.fineTuning.jobs.cancel("ftjob-abc123"); console.log(fineTune); } main(); response: | { "object": "fine_tuning.job", "id": "ftjob-abc123", "model": "gpt-3.5-turbo-0613", "created_at": 1689376978, "fine_tuned_model": null, "organization_id": "org-123", "result_files": [], "hyperparameters": { "n_epochs": "auto" }, "status": "cancelled", "validation_file": "file-abc123", "training_file": "file-abc123" } components: securitySchemes: ApiKeyAuth: type: http scheme: bearer schemas: FineTuningJob: type: object title: FineTuningJob description: > The `fine_tuning.job` object represents a fine-tuning job that has been created through the API. properties: id: type: string description: The object identifier, which can be referenced in the API endpoints. created_at: type: integer description: >- The Unix timestamp (in seconds) for when the fine-tuning job was created. error: type: object nullable: true description: >- For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure. properties: code: type: string description: A machine-readable error code. message: type: string description: A human-readable error message. param: type: string description: >- The parameter that was invalid, usually `training_file` or `validation_file`. This field will be null if the failure was not parameter-specific. nullable: true required: - code - message - param fine_tuned_model: type: string nullable: true description: >- The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running. finished_at: type: integer nullable: true description: >- 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: type: object description: >- The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. properties: n_epochs: oneOf: - type: string enum: - auto - type: integer minimum: 1 maximum: 50 default: auto description: >- The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. "auto" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs. required: - n_epochs model: type: string description: The base model that is being fine-tuned. object: type: string description: The object type, which is always "fine_tuning.job". enum: - fine_tuning.job organization_id: type: string description: The organization that owns the fine-tuning job. result_files: type: array description: >- The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents). items: type: string example: file-abc123 status: type: string description: >- The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. enum: - validating_files - queued - running - succeeded - failed - cancelled trained_tokens: type: integer nullable: true description: >- 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. training_file: type: string description: >- The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents). validation_file: type: string nullable: true description: >- The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents). required: - created_at - error - finished_at - fine_tuned_model - hyperparameters - id - model - object - organization_id - result_files - status - trained_tokens - training_file - validation_file x-oaiMeta: name: The fine-tuning job object example: | { "object": "fine_tuning.job", "id": "ftjob-abc123", "model": "davinci-002", "created_at": 1692661014, "finished_at": 1692661190, "fine_tuned_model": "ft:davinci-002:my-org:custom_suffix:7q8mpxmy", "organization_id": "org-123", "result_files": [ "file-abc123" ], "status": "succeeded", "validation_file": null, "training_file": "file-abc123", "hyperparameters": { "n_epochs": 4, }, "trained_tokens": 5768 } ListPaginatedFineTuningJobsResponse: type: object properties: data: type: array items: $ref: '#/components/schemas/FineTuningJob' has_more: type: boolean object: type: string enum: - list required: - object - data - has_more ListFineTuningJobEventsResponse: type: object properties: data: type: array items: $ref: '#/components/schemas/FineTuningJobEvent' object: type: string enum: - list required: - object - data security: - ApiKeyAuth: [] x-oaiMeta: groups: - id: audio title: Audio description: | Learn how to turn audio into text or text into audio. Related guide: [Speech to text](/docs/guides/speech-to-text) sections: - type: endpoint key: createSpeech path: createSpeech - type: endpoint key: createTranscription path: createTranscription - type: endpoint key: createTranslation path: createTranslation - id: chat title: Chat description: > Given a list of messages comprising a conversation, the model will return a response. Related guide: [Chat Completions](/docs/guides/text-generation) sections: - type: endpoint key: createChatCompletion path: create - type: object key: CreateChatCompletionResponse path: object - type: object key: CreateChatCompletionStreamResponse path: streaming - id: embeddings title: Embeddings description: > Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. Related guide: [Embeddings](/docs/guides/embeddings) sections: - type: endpoint key: createEmbedding path: create - type: object key: Embedding path: object - id: fine-tuning title: Fine-tuning description: > Manage fine-tuning jobs to tailor a model to your specific training data. Related guide: [Fine-tune models](/docs/guides/fine-tuning) sections: - type: endpoint key: createFineTuningJob path: create - type: endpoint key: listPaginatedFineTuningJobs path: list - type: endpoint key: listFineTuningEvents path: list-events - type: endpoint key: retrieveFineTuningJob path: retrieve - type: endpoint key: cancelFineTuningJob path: cancel - type: object key: FineTuningJob path: object - type: object key: FineTuningJobEvent path: event-object - id: files title: Files description: > Files are used to upload documents that can be used with features like [Assistants](/docs/api-reference/assistants) and [Fine-tuning](/docs/api-reference/fine-tuning). sections: - type: endpoint key: createFile path: create - type: endpoint key: listFiles path: list - type: endpoint key: retrieveFile path: retrieve - type: endpoint key: deleteFile path: delete - type: endpoint key: downloadFile path: retrieve-contents - type: object key: OpenAIFile path: object - id: images title: Images description: > Given a prompt and/or an input image, the model will generate a new image. Related guide: [Image generation](/docs/guides/images) sections: - type: endpoint key: createImage path: create - type: endpoint key: createImageEdit path: createEdit - type: endpoint key: createImageVariation path: createVariation - type: object key: Image path: object - id: models title: Models description: > List and describe the various models available in the API. You can refer to the [Models](/docs/models) documentation to understand what models are available and the differences between them. sections: - type: endpoint key: listModels path: list - type: endpoint key: retrieveModel path: retrieve - type: endpoint key: deleteModel path: delete - type: object key: Model path: object - id: moderations title: Moderations description: > Given a input text, outputs if the model classifies it as violating OpenAI's content policy. Related guide: [Moderations](/docs/guides/moderation) sections: - type: endpoint key: createModeration path: create - type: object key: CreateModerationResponse path: object - id: assistants title: Assistants beta: true description: | Build assistants that can call models and use tools to perform tasks. [Get started with the Assistants API](/docs/assistants) sections: - type: endpoint key: createAssistant path: createAssistant - type: endpoint key: createAssistantFile path: createAssistantFile - type: endpoint key: listAssistants path: listAssistants - type: endpoint key: listAssistantFiles path: listAssistantFiles - type: endpoint key: getAssistant path: getAssistant - type: endpoint key: getAssistantFile path: getAssistantFile - type: endpoint key: modifyAssistant path: modifyAssistant - type: endpoint key: deleteAssistant path: deleteAssistant - type: endpoint key: deleteAssistantFile path: deleteAssistantFile - type: object key: AssistantObject path: object - type: object key: AssistantFileObject path: file-object - id: threads title: Threads beta: true description: | Create threads that assistants can interact with. Related guide: [Assistants](/docs/assistants/overview) sections: - type: endpoint key: createThread path: createThread - type: endpoint key: getThread path: getThread - type: endpoint key: modifyThread path: modifyThread - type: endpoint key: deleteThread path: deleteThread - type: object key: ThreadObject path: object - id: messages title: Messages beta: true description: | Create messages within threads Related guide: [Assistants](/docs/assistants/overview) sections: - type: endpoint key: createMessage path: createMessage - type: endpoint key: listMessages path: listMessages - type: endpoint key: listMessageFiles path: listMessageFiles - type: endpoint key: getMessage path: getMessage - type: endpoint key: getMessageFile path: getMessageFile - type: endpoint key: modifyMessage path: modifyMessage - type: object key: MessageObject path: object - type: object key: MessageFileObject path: file-object - id: runs title: Runs beta: true description: | Represents an execution run on a thread. Related guide: [Assistants](/docs/assistants/overview) sections: - type: endpoint key: createRun path: createRun - type: endpoint key: createThreadAndRun path: createThreadAndRun - type: endpoint key: listRuns path: listRuns - type: endpoint key: listRunSteps path: listRunSteps - type: endpoint key: getRun path: getRun - type: endpoint key: getRunStep path: getRunStep - type: endpoint key: modifyRun path: modifyRun - type: endpoint key: submitToolOuputsToRun path: submitToolOutputs - type: endpoint key: cancelRun path: cancelRun - type: object key: RunObject path: object - type: object key: RunStepObject path: step-object - id: completions title: Completions legacy: true description: > Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our [Chat Completions API](/docs/guides/text-generation/text-generation-models) to leverage our best and newest models. Most models that support the legacy Completions endpoint [will be shut off on January 4th, 2024](/docs/deprecations/2023-07-06-gpt-and-embeddings). sections: - type: endpoint key: createCompletion path: create - type: object key: CreateCompletionResponse path: object