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

# Create a fine-tuning dataset proposal

> Start a CrewAI run that assembles domain knowledge into Q/A examples.

Crew events are published under the job's UUID; the portal polls
``/api/events/{job_id}``. The response carries that ID as ``X-Correlation-ID``.



## OpenAPI

````yaml post /api/finetune/datasets
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/finetune/datasets:
    post:
      tags:
        - AutoLLM
      summary: Create a fine-tuning dataset proposal
      description: >-
        Start a CrewAI run that assembles domain knowledge into Q/A examples.


        Crew events are published under the job's UUID; the portal polls

        ``/api/events/{job_id}``. The response carries that ID as
        ``X-Correlation-ID``.
      operationId: create_dataset_api_finetune_datasets_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FineTuneDatasetRequest'
      responses:
        '202':
          description: Crew run started. Poll the job for the proposal.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FineTuneDatasetProposal'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    FineTuneDatasetRequest:
      properties:
        domain:
          type: string
          maxLength: 512
          title: Domain
          description: DataHub domain name or URN whose knowledge seeds the dataset.
        base_model:
          type: string
          maxLength: 256
          title: Base Model
          description: >-
            Base model this dataset will fine-tune. Must be present in
            FINETUNE_BASE_MODEL_ALLOWLIST; validated server-side.
        name:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Name
          description: Human-friendly dataset name. Defaults to '<domain>-finetune'.
        extra_instructions:
          anyOf:
            - type: string
              maxLength: 20000
            - type: 'null'
          title: Extra Instructions
          description: >-
            Free-form guidance and facts the user wants baked in — extra context
            the crew should weave into the training examples.
        target_examples:
          anyOf:
            - type: integer
              maximum: 500
              minimum: 1
            - type: 'null'
          title: Target Examples
          description: >-
            Soft target for how many Q/A examples to generate. Clamped by
            FINETUNE_DATASET_CREW_MAX_EXAMPLES.
        include_glossary:
          type: boolean
          title: Include Glossary
          default: true
        include_documents:
          type: boolean
          title: Include Documents
          default: true
        include_lineage:
          type: boolean
          title: Include Lineage
          default: true
        include_tags:
          type: boolean
          title: Include Tags
          default: true
        include_data_products:
          type: boolean
          title: Include Data Products
          default: true
        owner:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Owner
          description: >-
            Owner username. Ignored for non-admin callers (the authenticated
            user is always the owner); admins may set it to create on behalf of
            another user.
      type: object
      required:
        - domain
        - base_model
      title: FineTuneDatasetRequest
      description: Start a dataset-generation run for a DataHub domain.
    FineTuneDatasetProposal:
      properties:
        job_id:
          type: string
          format: uuid
          title: Job Id
        status:
          $ref: '#/components/schemas/FineTuneDatasetStatusEnum'
        name:
          type: string
          title: Name
        domain:
          type: string
          title: Domain
        base_model:
          type: string
          title: Base Model
        owner:
          type: string
          title: Owner
        example_count:
          type: integer
          title: Example Count
          default: 0
        coverage:
          anyOf:
            - $ref: '#/components/schemas/CoverageStats'
            - type: 'null'
        sample_examples:
          items:
            $ref: '#/components/schemas/QAExample'
          type: array
          title: Sample Examples
        notes:
          anyOf:
            - type: string
            - type: 'null'
          title: Notes
        proposed_dataset_s3:
          anyOf:
            - type: string
            - type: 'null'
          title: Proposed Dataset S3
        approved_dataset_s3:
          anyOf:
            - type: string
            - type: 'null'
          title: Approved Dataset S3
        mlflow_dataset_uri:
          anyOf:
            - type: string
            - type: 'null'
          title: Mlflow Dataset Uri
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - job_id
        - status
        - name
        - domain
        - base_model
        - owner
        - created_at
        - updated_at
      title: FineTuneDatasetProposal
      description: >-
        The crew's proposed dataset, returned for review.


        The full example set lives in S3 (``proposed_dataset_s3`` / after
        approval,

        ``approved_dataset_s3``). ``sample_examples`` is a bounded preview.
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FineTuneDatasetStatusEnum:
      type: string
      enum:
        - running
        - pending_approval
        - failed
        - approved
        - materializing
        - complete
      title: FineTuneDatasetStatusEnum
      description: Lifecycle of a fine-tuning dataset job.
    CoverageStats:
      properties:
        glossary_terms:
          type: integer
          title: Glossary Terms
          default: 0
        documents:
          type: integer
          title: Documents
          default: 0
        datasets:
          type: integer
          title: Datasets
          default: 0
        tags:
          type: integer
          title: Tags
          default: 0
        data_products:
          type: integer
          title: Data Products
          default: 0
        total_examples:
          type: integer
          title: Total Examples
          default: 0
      type: object
      title: CoverageStats
      description: How much of the domain the crew drew on.
    QAExample:
      properties:
        messages:
          items:
            $ref: '#/components/schemas/ChatMessage'
          type: array
          maxItems: 50
          minItems: 1
          title: Messages
          description: Chat turns; typically a user question and an assistant answer.
        provenance:
          anyOf:
            - type: string
            - type: 'null'
          title: Provenance
          description: Source of the example — a DataHub URN, document name, or note.
        category:
          anyOf:
            - type: string
            - type: 'null'
          title: Category
          description: >-
            Knowledge category: glossary | document | lineage | tag |
            data_product | user.
      type: object
      required:
        - messages
      title: QAExample
      description: A single instruction-tuning example in chat format.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ChatMessage:
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
          title: Role
        content:
          type: string
          maxLength: 100000
          title: Content
      type: object
      required:
        - role
        - content
      title: ChatMessage
      description: One turn in a chat-format training example.
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````