> ## Documentation Index
> Fetch the complete documentation index at: https://openai-hd4n6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a 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.

[Learn more about fine-tuning](/docs/guides/fine-tuning)




## OpenAPI

````yaml api-definition.yaml post /fine_tuning/jobs
openapi: 3.0.0
info:
  title: OpenAI API
  description: >-
    The OpenAI REST API. Please see
    https://platform.openai.com/docs/api-reference for more details.
  version: 2.3.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
security:
  - ApiKeyAuth: []
tags:
  - name: Assistants
    description: Build Assistants that can call models and use tools.
  - name: Audio
    description: Turn audio into text or text into audio.
  - name: Chat
    description: >-
      Given a list of messages comprising a conversation, the model will return
      a response.
  - name: Completions
    description: >-
      Given a prompt, the model will return one or more predicted completions,
      and can also return the probabilities of alternative tokens at each
      position.
  - name: Embeddings
    description: >-
      Get a vector representation of a given input that can be easily consumed
      by machine learning models and algorithms.
  - name: Evals
    description: Manage and run evals in the OpenAI platform.
  - name: Fine-tuning
    description: Manage fine-tuning jobs to tailor a model to your specific training data.
  - name: Batch
    description: Create large batches of API requests to run asynchronously.
  - name: Files
    description: >-
      Files are used to upload documents that can be used with features like
      Assistants and Fine-tuning.
  - name: Uploads
    description: Use Uploads to upload large files in multiple parts.
  - name: Images
    description: Given a prompt and/or an input image, the model will generate a new image.
  - name: Models
    description: List and describe the various models available in the API.
  - name: Moderations
    description: >-
      Given text and/or image inputs, classifies if those inputs are potentially
      harmful.
  - name: Audit Logs
    description: List user actions and configuration changes within this organization.
paths:
  /fine_tuning/jobs:
    post:
      tags:
        - Fine-tuning
      summary: Create a fine-tuning job
      description: >
        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)
      operationId: createFineTuningJob
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFineTuningJobRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FineTuningJob'
components:
  schemas:
    CreateFineTuningJobRequest:
      type: object
      properties:
        model:
          description: >
            The name of the model to fine-tune. You can select one of the

            [supported
            models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
          example: gpt-4o-mini
          anyOf:
            - type: string
            - type: string
              enum:
                - babbage-002
                - davinci-002
                - gpt-3.5-turbo
                - gpt-4o-mini
          x-oaiTypeLabel: string
        training_file:
          description: >
            The ID of an uploaded file that contains training data.


            See [upload file](/docs/api-reference/files/create) 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](/docs/api-reference/fine-tuning/chat-input),
            [completions](/docs/api-reference/fine-tuning/completions-input)
            format, or if the fine-tuning method uses the
            [preference](/docs/api-reference/fine-tuning/preference-input)
            format.


            See the [fine-tuning guide](/docs/guides/fine-tuning) for more
            details.
          type: string
          example: file-abc123
        hyperparameters:
          type: object
          description: >
            The hyperparameters used for the fine-tuning job.

            This value is now deprecated in favor of `method`, and should be
            passed in under the `method` parameter.
          properties:
            batch_size:
              description: >
                Number of examples in each batch. A larger batch size means that
                model parameters

                are updated less frequently, but with lower variance.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 256
              default: auto
            learning_rate_multiplier:
              description: >
                Scaling factor for the learning rate. A smaller learning rate
                may be useful to avoid

                overfitting.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: number
                  minimum: 0
                  exclusiveMinimum: true
              default: auto
            n_epochs:
              description: >
                The number of epochs to train the model for. An epoch refers to
                one full cycle

                through the training dataset.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 50
              default: auto
          deprecated: true
        suffix:
          description: >
            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`.
          type: string
          minLength: 1
          maxLength: 64
          default: null
          nullable: true
        validation_file:
          description: >
            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](/docs/guides/fine-tuning) for more
            details.
          type: string
          nullable: true
          example: file-abc123
        integrations:
          type: array
          description: A list of integrations to enable for your fine-tuning job.
          nullable: true
          items:
            type: object
            required:
              - type
              - wandb
            properties:
              type:
                description: >
                  The type of integration to enable. Currently, only "wandb"
                  (Weights and Biases) is supported.
                oneOf:
                  - type: string
                    enum:
                      - wandb
                    x-stainless-const: true
              wandb:
                type: object
                description: >
                  The settings for your integration with Weights and Biases.
                  This payload specifies the project that

                  metrics will be sent to. Optionally, you can set an explicit
                  display name for your run, add tags

                  to your run, and set a default entity (team, username, etc) to
                  be associated with your run.
                required:
                  - project
                properties:
                  project:
                    description: >
                      The name of the project that the new run will be created
                      under.
                    type: string
                    example: my-wandb-project
                  name:
                    description: >
                      A display name to set for the run. If not set, we will use
                      the Job ID as the name.
                    nullable: true
                    type: string
                  entity:
                    description: >
                      The entity to use for the run. This allows you to set the
                      team or username of the WandB user that you would

                      like associated with the run. If not set, the default
                      entity for the registered WandB API key is used.
                    nullable: true
                    type: string
                  tags:
                    description: >
                      A list of tags to be attached to the newly created run.
                      These tags are passed through directly to WandB. Some

                      default tags are generated by OpenAI: "openai/finetune",
                      "openai/{base-model}", "openai/{ftjob-abcdef}".
                    type: array
                    items:
                      type: string
                      example: custom-tag
        seed:
          description: >
            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.
          type: integer
          nullable: true
          minimum: 0
          maximum: 2147483647
          example: 42
        method:
          $ref: '#/components/schemas/FineTuneMethod'
        metadata:
          $ref: '#/components/schemas/Metadata'
      required:
        - model
        - training_file
    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. This value will
            only be returned when running `supervised` jobs.
          properties:
            batch_size:
              description: >
                Number of examples in each batch. A larger batch size means that
                model parameters

                are updated less frequently, but with lower variance.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 256
              default: auto
            learning_rate_multiplier:
              description: >
                Scaling factor for the learning rate. A smaller learning rate
                may be useful to avoid

                overfitting.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: number
                  minimum: 0
                  exclusiveMinimum: true
              default: auto
            n_epochs:
              description: >
                The number of epochs to train the model for. An epoch refers to
                one full cycle

                through the training dataset.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 50
              default: auto
        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
          x-stainless-const: true
        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).
        integrations:
          type: array
          nullable: true
          description: A list of integrations to enable for this fine-tuning job.
          maxItems: 5
          items:
            oneOf:
              - $ref: '#/components/schemas/FineTuningIntegration'
            x-oaiExpandable: true
        seed:
          type: integer
          description: The seed used for the fine-tuning job.
        estimated_finish:
          type: integer
          nullable: true
          description: >-
            The Unix timestamp (in seconds) for when the fine-tuning job is
            estimated to finish. The value will be null if the fine-tuning job
            is not running.
        method:
          $ref: '#/components/schemas/FineTuneMethod'
        metadata:
          $ref: '#/components/schemas/Metadata'
      required:
        - created_at
        - error
        - finished_at
        - fine_tuned_model
        - hyperparameters
        - id
        - model
        - object
        - organization_id
        - result_files
        - status
        - trained_tokens
        - training_file
        - validation_file
        - seed
      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,
                "batch_size": 1,
                "learning_rate_multiplier": 1.0
            },
            "trained_tokens": 5768,
            "integrations": [],
            "seed": 0,
            "estimated_finish": 0,
            "method": {
              "type": "supervised",
              "supervised": {
                "hyperparameters": {
                  "n_epochs": 4,
                  "batch_size": 1,
                  "learning_rate_multiplier": 1.0
                }
              }
            },
            "metadata": {
              "key": "value"
            }
          }
    FineTuneMethod:
      type: object
      description: The method used for fine-tuning.
      properties:
        type:
          type: string
          description: The type of method. Is either `supervised` or `dpo`.
          enum:
            - supervised
            - dpo
        supervised:
          $ref: '#/components/schemas/FineTuneSupervisedMethod'
        dpo:
          $ref: '#/components/schemas/FineTuneDPOMethod'
    Metadata:
      type: object
      description: >
        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.
      additionalProperties:
        type: string
      x-oaiTypeLabel: map
      nullable: true
    FineTuningIntegration:
      type: object
      title: Fine-Tuning Job Integration
      required:
        - type
        - wandb
      properties:
        type:
          type: string
          description: The type of the integration being enabled for the fine-tuning job
          enum:
            - wandb
          x-stainless-const: true
        wandb:
          type: object
          description: >
            The settings for your integration with Weights and Biases. This
            payload specifies the project that

            metrics will be sent to. Optionally, you can set an explicit display
            name for your run, add tags

            to your run, and set a default entity (team, username, etc) to be
            associated with your run.
          required:
            - project
          properties:
            project:
              description: |
                The name of the project that the new run will be created under.
              type: string
              example: my-wandb-project
            name:
              description: >
                A display name to set for the run. If not set, we will use the
                Job ID as the name.
              nullable: true
              type: string
            entity:
              description: >
                The entity to use for the run. This allows you to set the team
                or username of the WandB user that you would

                like associated with the run. If not set, the default entity for
                the registered WandB API key is used.
              nullable: true
              type: string
            tags:
              description: >
                A list of tags to be attached to the newly created run. These
                tags are passed through directly to WandB. Some

                default tags are generated by OpenAI: "openai/finetune",
                "openai/{base-model}", "openai/{ftjob-abcdef}".
              type: array
              items:
                type: string
                example: custom-tag
    FineTuneSupervisedMethod:
      type: object
      description: Configuration for the supervised fine-tuning method.
      properties:
        hyperparameters:
          type: object
          description: The hyperparameters used for the fine-tuning job.
          properties:
            batch_size:
              description: >
                Number of examples in each batch. A larger batch size means that
                model parameters are updated less frequently, but with lower
                variance.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 256
              default: auto
            learning_rate_multiplier:
              description: >
                Scaling factor for the learning rate. A smaller learning rate
                may be useful to avoid overfitting.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: number
                  minimum: 0
                  exclusiveMinimum: true
              default: auto
            n_epochs:
              description: >
                The number of epochs to train the model for. An epoch refers to
                one full cycle through the training dataset.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 50
              default: auto
    FineTuneDPOMethod:
      type: object
      description: Configuration for the DPO fine-tuning method.
      properties:
        hyperparameters:
          type: object
          description: The hyperparameters used for the fine-tuning job.
          properties:
            beta:
              description: >
                The beta value for the DPO method. A higher beta value will
                increase the weight of the penalty between the policy and
                reference model.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: number
                  minimum: 0
                  maximum: 2
                  exclusiveMinimum: true
              default: auto
            batch_size:
              description: >
                Number of examples in each batch. A larger batch size means that
                model parameters are updated less frequently, but with lower
                variance.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 256
              default: auto
            learning_rate_multiplier:
              description: >
                Scaling factor for the learning rate. A smaller learning rate
                may be useful to avoid overfitting.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: number
                  minimum: 0
                  exclusiveMinimum: true
              default: auto
            n_epochs:
              description: >
                The number of epochs to train the model for. An epoch refers to
                one full cycle through the training dataset.
              oneOf:
                - type: string
                  enum:
                    - auto
                  x-stainless-const: true
                - type: integer
                  minimum: 1
                  maximum: 50
              default: auto
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer

````