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

# Create Fine Tune



## OpenAPI

````yaml POST /fine_tunes/create_finetune
openapi: 3.0.1
info:
  title: FlexAI API
  description: API for managing datasets, fine-tuning models, and handling ML tasks
  version: 1.0.0
servers:
  - url: https://api.getflex.ai/v1
security:
  - bearerAuth: []
paths:
  /fine_tunes/create_finetune:
    post:
      summary: Create Fine-tune
      operationId: createFinetune
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFinetuneRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateFinetuneRequest:
      type: object
      required:
        - name
        - dataset_id
        - model
        - n_epochs
        - train_with_lora
      properties:
        name:
          type: string
        model:
          type: string
        dataset_id:
          type: string
        n_epochs:
          type: integer
        train_with_lora:
          type: boolean
        batch_size:
          type: integer
        wandb_key:
          type: string
        learning_rate:
          type: number
        n_checkpoints_and_evaluations_per_epoch:
          type: integer
          default: 1
        save_only_best_checkpoint:
          type: boolean
          default: false
        lora_config:
          type: object
          additionalProperties: true
        early_stopping_config:
          type: object
          additionalProperties: true
    Task:
      type: object
      properties:
        id:
          type: string
        config:
          type: object
        user_id:
          type: string
        model_id:
          type: string
        name:
          type: string
        checkpoints_count:
          type: integer
        total_steps:
          type: integer
        dataset_id:
          type: string
        engine_data:
          type: object
          properties:
            runpod_run_id:
              type: string
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  responses:
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````