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

# Train Model

> Create and train a new model.

Reference training data by `dataset_id` (uses the latest ready version) or by a specific `dataset_version_id` for reproducibility.

Poll `GET /models/{model_id}` until `status` becomes `ready` (or poll `GET /jobs/{job_id}` for more detail).

See [Capabilities](/capabilities/overview) for details on each model type, required parameters, and training metrics. See [Output Formats](/api-reference/inference#output-formats) for output columns by model type.


## OpenAPI

````yaml /openapi.json post /models/train
openapi: 3.1.0
info:
  title: Woodwide API
  description: API service for the Woodwide platform
  version: 0.1.0
servers:
  - url: https://api.woodwide.ai
    description: Production
security: []
paths:
  /models/train:
    post:
      tags:
        - Models
      summary: Train Model
      description: Create and train a new model.
      operationId: train_model_models_train_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TrainModelRequest'
            example:
              model_name: churn_predictor
              model_type: prediction
              dataset_id: a1b2c3d4-0000-0000-0000-000000000001
              label_column: churned
        required: true
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrainModelResponse'
              example:
                model:
                  id: b2c3d4e5-0000-0000-0000-000000000001
                  version_id: b2c3d4e5-0000-0000-0000-000000000002
                  version_number: 1
                job_id: b2c3d4e5-0000-0000-0000-000000000003
                status: queued
                woodwide_runtime_version: '0.1'
        '401':
          description: Unauthorized -- API key is missing or invalid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Not authenticated
        '403':
          description: >-
            Forbidden -- your API key does not have permission for this
            resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Forbidden
        '404':
          description: Not Found -- the requested resource does not exist.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: >-
            Too Many Requests -- you have exceeded the rate limit. Heavy
            operations (training, inference, dataset uploads) are limited to 60
            requests per minute per API key. All other endpoints are limited to
            600 requests per minute per API key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Rate limit exceeded. Retry after a short delay.
      security:
        - HTTPBearer: []
components:
  schemas:
    TrainModelRequest:
      properties:
        model_name:
          type: string
          title: Model Name
        model_description:
          type: string
          title: Model Description
        model_type:
          $ref: '#/components/schemas/ModelType'
          example: prediction
        dataset_version_id:
          type: string
          format: uuid
          title: Dataset Version Id
          description: >-
            Pin a specific dataset version. If omitted, the latest ready version
            is used.
        dataset_id:
          type: string
          format: uuid
          title: Dataset Id
          description: >-
            Dataset to train on (uses latest ready version). Provide this OR
            dataset_version_id.
        label_column:
          type: string
          title: Label Column
          description: >-
            Target column for prediction models. Required for prediction,
            forbidden for other types.
        input_columns:
          items:
            type: string
          type: array
          title: Input Columns
          description: >-
            Columns to use as features. If omitted, all columns except label are
            used.
      type: object
      required:
        - model_name
        - model_type
      title: TrainModelRequest
      description: |-
        Request to train a new model.

        Reference training data by ``dataset_id`` (resolves to the latest
        ready version automatically) or by ``dataset_version_id`` for
        reproducibility.  In most cases, just pass ``dataset_id``.
      example:
        model_name: churn_predictor
        model_type: prediction
        dataset_id: a1b2c3d4-0000-0000-0000-000000000001
        label_column: churned
    TrainModelResponse:
      properties:
        model:
          $ref: '#/components/schemas/ModelVersionRef'
        job_id:
          type: string
          format: uuid
          title: Job Id
        status:
          type: string
          title: Status
        woodwide_runtime_version:
          type: string
          title: Woodwide Runtime Version
      type: object
      required:
        - model
        - job_id
        - status
        - woodwide_runtime_version
      title: TrainModelResponse
      description: Response for training a model.
      example:
        model:
          id: b2c3d4e5-0000-0000-0000-000000000001
          version_id: b2c3d4e5-0000-0000-0000-000000000002
          version_number: 1
        job_id: b2c3d4e5-0000-0000-0000-000000000003
        status: queued
        woodwide_runtime_version: '0.1'
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
      description: Returned when request parameters or body fail validation.
    ModelType:
      type: string
      enum:
        - prediction
        - anomaly
        - embedding
        - clustering
        - factors
        - search
      title: ModelType
      description: |-
        Canonical model types supported by the platform.

        - ``prediction`` -- Supervised prediction (classification or regression)
          on a target column.
        - ``anomaly`` -- Unsupervised anomaly detection. Returns anomaly scores
          and anomalous row IDs.
        - ``embedding`` -- Generate dense vector embeddings for each row.
        - ``clustering`` -- Unsupervised clustering. Returns cluster labels and
          descriptions.
        - ``factors`` -- Factor analysis / dimensionality reduction.
        - ``search`` -- Semantic nearest-neighbor search over the training
          dataset.
    ModelVersionRef:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        version_id:
          type: string
          format: uuid
          title: Version Id
        version_number:
          type: integer
          title: Version Number
      type: object
      required:
        - id
        - version_id
        - version_number
      title: ModelVersionRef
      description: Model version reference.
    ValidationError:
      type: object
      required:
        - loc
        - msg
        - type
      properties:
        loc:
          type: array
          items:
            type: string
          title: Location
          description: Path to the field that caused the error.
        msg:
          type: string
          title: Message
          description: Human-readable error message.
        type:
          type: string
          title: Error Type
          description: Machine-readable error type identifier.
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````