> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a fine tuning job

> Create a new fine tuning job.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/ai/inference.yml post /ai/fine_tuning/jobs
openapi: 3.1.0
info:
  title: Telnyx AI Inference API
  version: 2.0.0
  description: API for AI inference, including chat completions, fine-tuning, and models.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /ai/fine_tuning/jobs:
    post:
      tags:
        - Fine Tuning
      summary: Create a fine tuning job
      description: Create a new fine tuning job.
      operationId: create_new_finetuningjob_public_finetuning_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFineTuningJobRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FineTuningJob'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const fineTuningJob = await client.ai.fineTuning.jobs.create({
              model: 'model',
              training_file: 'training_file',
            });

            console.log(fineTuningJob.id);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            fine_tuning_job = client.ai.fine_tuning.jobs.create(
                model="model",
                training_file="training_file",
            )
            print(fine_tuning_job.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.AI.FineTuning.Jobs.New(context.TODO(), telnyx.AIFineTuningJobNewParams{\n\t\tModel:        \"model\",\n\t\tTrainingFile: \"training_file\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", fineTuningJob.ID)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.ai.finetuning.jobs.FineTuningJob;
            import com.telnyx.sdk.models.ai.finetuning.jobs.JobCreateParams;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    JobCreateParams params = JobCreateParams.builder()
                        .model("model")
                        .trainingFile("training_file")
                        .build();
                    FineTuningJob fineTuningJob = client.ai().fineTuning().jobs().create(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            fine_tuning_job = telnyx.ai.fine_tuning.jobs.create(model: "model",
            training_file: "training_file")


            puts(fine_tuning_job)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $fineTuningJob = $client->ai->fineTuning->jobs->create(
                model: 'model',
                trainingFile: 'training_file',
                hyperparameters: ['nEpochs' => 1],
                suffix: 'suffix',
              );

              var_dump($fineTuningJob);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:fine-tuning:jobs create \
              --api-key 'My API Key' \
              --model model \
              --training-file training_file
components:
  schemas:
    CreateFineTuningJobRequest:
      properties:
        model:
          type: string
          description: The base model that is being fine-tuned.
        training_file:
          type: string
          description: The storage bucket or object used for training.
        suffix:
          type: string
          description: Optional suffix to append to the fine tuned model's name.
        hyperparameters:
          type: object
          description: The hyperparameters used for the fine-tuning job.
          properties:
            n_epochs:
              type: integer
              minimum: 1
              maximum: 10
              default: 3
              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.
      type: object
      required:
        - model
        - training_file
      title: CreateFineTuningJobRequest
    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 name of the fine-tuned model that is being created.
        created_at:
          type: integer
          description: >-
            The Unix timestamp (in seconds) for when the fine-tuning job was
            created.
        finished_at:
          type:
            - integer
            - 'null'
          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.
          properties:
            n_epochs:
              type: integer
              minimum: 1
              maximum: 10
              default: 3
              description: >-
                The number of epochs to train the model for. An epoch refers to
                one full cycle through the training dataset.
          required:
            - n_epochs
        model:
          type: string
          description: The base model that is being fine-tuned.
        organization_id:
          type: string
          description: The organization that owns the fine-tuning job.
        status:
          type: string
          description: The current status of the fine-tuning job.
          enum:
            - queued
            - running
            - succeeded
            - failed
            - cancelled
        trained_tokens:
          type:
            - integer
            - 'null'
          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 storage bucket or object used for training.
      required:
        - created_at
        - finished_at
        - hyperparameters
        - id
        - model
        - organization_id
        - status
        - trained_tokens
        - training_file
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    ValidationError:
      title: ValidationError
      required:
        - loc
        - msg
        - type
      type: object
      properties:
        loc:
          title: Location
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````