---
title: "This endpoint trains a new ML Model."
method: POST
path: "/api/projects/{projectName}/models"
---

# This endpoint trains a new ML Model.

`POST /api/projects/{projectName}/models`

Starts training a new Machine Learning model.

## Path parameters

- `projectName` string, required

## Request body

- object
  - `query` string — The SQL CREATE MODEL statement used to train this model. See the [CREATE MODEL](https://docs.mindsdb.com/sql/create/model) statement

## Response `200`

Model training started

- Model
  - `name` string
  - `accuracy` number — Accuracy of trained model between 0 and 1
  - `active` boolean — Whether or not this model is currenty the active version
  - `version` number — Version of this model
  - `status` string — Current status of this model (generating | creating | complete | error)
  - `predict` string — Column name that this model predicts
  - `mindsdb_version` string — MindsDB version associated with this model
  - `error` string — Error encountered during training, if applicable
  - `fetch_data_query` string — SQL query used to fetch training data for this model
  - `created_at` string — Time model was created at in YYYY-MM-DD HH:MM:SS format (trained models only)
  - `training_time` string — How long training this model took in HH:MM:SS format (trained models only)
  - `update` string — Set to "available" when a new version of MindsDB is available that makes the model obsolete, or when new data is available in the data that was used to train the model (trained models only).

## Other responses

- `400` — Bad request
- `401` — Invalid API key error message
- `404` — Project not found
- `500` — Server error

---

[API](https://skmtc.net/mindsdb/apis/mindsdb-api.md) · [All operations](https://skmtc.net/mindsdb/apis/mindsdb-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mindsdb/mindsdb-api/versions/387ff52538f9/schema)
