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

# Create an ML Model

> Create a new ML model within an ML model service

# Create an ML Model

Create a new ML model within an ML model service.

## Body Parameters

**name** `string` *required*

Name of the ML model. Must be unique within the parent ML model service.

**service** `string` *required*

Fully qualified name of the parent MlModelService, for example `mlflow_svc`.

**algorithm** `string`

Algorithm used by the ML model, for example `KMeans`, `RandomForest`, `XGBoost`, `Neural Network`.

**displayName** `string`

Human-readable display name for the ML model.

**description** `string`

Description of the ML model in Markdown format.

**mlFeatures** `array`

Array of ML features used by the model.

**properties**

**name** `string`

Name of the feature.

**dataType** `string`

Data type of the feature, for example `numerical`, `categorical`.

**featureSources** `array`

Sources of the feature data.

**properties**

**name** `string`

Name of the feature source.

**dataType** `string`

Data type of the source.

**dataSource** `object`

Reference to the source entity, for example a table or column.

**mlHyperParameters** `array`

Array of hyperparameters used by the model.

**properties**

**name** `string`

Name of the hyperparameter.

**value** `string`

Value of the hyperparameter.

**target** `string`

Target variable or objective of the ML model.

**server** `string`

Endpoint URL for the model serving server.

**dashboard** `object`

Reference to an associated dashboard entity.

**properties**

**id** `string`

UUID of the dashboard entity.

**type** `string`

Type of entity (always `dashboard`).

**owners** `array`

Array of owner references (users or teams) to assign to the ML model.

**properties**

**id** `string`

UUID of the owner entity.

**type** `string`

Type of owner entity, for example `user`, `team`.

**name** `string`

Name of the owner entity.

**domains** `array`

Fully qualified names of the domains to assign for governance purposes.

**tags** `array`

Array of classification tags to apply to the ML model.

**properties**

**tagFQN** `string` *required*

Fully qualified name of the tag.

**labelType** `string`

Type of label, for example `Manual`, `Derived`, `Propagated`.

**state** `string`

State of the tag, for example `Suggested`, `Confirmed`.

**extension** `object`

Custom property values defined by your organization's metadata schema.

```python POST /v1/mlmodels theme={null}
from metadata.sdk import configure
from metadata.sdk.entities import MLModels
from metadata.generated.schema.api.data.createMlModel import CreateMlModelRequest

configure(
    host="https://your-company.open-metadata.org/api",
    jwt_token="your-jwt-token"
)

request = CreateMlModelRequest(
    name="customer_segmentation",
    displayName="Customer Segmentation Model",
    service="mlflow_svc",
    algorithm="KMeans",
    description="Segments customers into groups based on purchasing behavior",
    mlFeatures=[
        {
            "name": "total_spend",
            "dataType": "numerical"
        },
        {
            "name": "purchase_frequency",
            "dataType": "numerical"
        }
    ],
    mlHyperParameters=[
        {"name": "n_clusters", "value": "5"},
        {"name": "max_iter", "value": "300"}
    ],
    target="customer_segment"
)

model = MLModels.create(request)
print(f"Created: {model.fullyQualifiedName.root}")
```

```java POST /v1/mlmodels theme={null}
import java.util.List;
import org.openmetadata.schema.api.data.CreateMlModel;
import org.openmetadata.schema.entity.data.MlModel;
import org.openmetadata.schema.type.MlFeature;
import org.openmetadata.schema.type.MlFeatureDataType;
import org.openmetadata.sdk.fluent.MlModels;

CreateMlModel request = new CreateMlModel()
    .withName("customer_segmentation")
    .withDisplayName("Customer Segmentation Model")
    .withService("mlflow_svc")
    .withAlgorithm("KMeans")
    .withDescription("Segments customers into groups based on purchasing behavior")
    .withMlFeatures(List.of(
        new MlFeature().withName("total_spend").withDataType(MlFeatureDataType.Numerical),
        new MlFeature().withName("purchase_frequency").withDataType(MlFeatureDataType.Numerical)));

MlModel model = MlModels.create(request);
```

```bash POST /v1/mlmodels theme={null}
curl -X POST "{base_url}/api/v1/mlmodels" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "customer_segmentation",
    "displayName": "Customer Segmentation Model",
    "service": "mlflow_svc",
    "algorithm": "KMeans",
    "description": "Segments customers into groups based on purchasing behavior",
    "mlFeatures": [
      {
        "name": "total_spend",
        "dataType": "numerical"
      },
      {
        "name": "purchase_frequency",
        "dataType": "numerical"
      }
    ],
    "mlHyperParameters": [
      {"name": "n_clusters", "value": "5"},
      {"name": "max_iter", "value": "300"}
    ],
    "target": "customer_segment"
  }'
```

```json Response theme={null}
{
  "id": "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2",
  "name": "customer_segmentation",
  "fullyQualifiedName": "mlflow_svc.customer_segmentation",
  "displayName": "Customer Segmentation Model",
  "description": "Segments customers into groups based on purchasing behavior",
  "algorithm": "KMeans",
  "mlFeatures": [
    {
      "name": "total_spend",
      "dataType": "numerical"
    },
    {
      "name": "purchase_frequency",
      "dataType": "numerical"
    }
  ],
  "mlHyperParameters": [
    {"name": "n_clusters", "value": "5"},
    {"name": "max_iter", "value": "300"}
  ],
  "target": "customer_segment",
  "version": 0.1,
  "updatedAt": 1769982669247,
  "updatedBy": "admin",
  "service": {
    "id": "ca22d46e-81b9-4e48-85b5-0adc44980da9",
    "type": "mlmodelService",
    "name": "mlflow_svc",
    "fullyQualifiedName": "mlflow_svc",
    "deleted": false
  },
  "serviceType": "Mlflow",
  "href": "http://localhost:8585/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2",
  "deleted": false,
  "owners": [],
  "tags": [],
  "followers": [],
  "votes": {
    "upVotes": 0,
    "downVotes": 0
  },
  "domains": []
}
```

***

## Returns

Returns the created ML model object with all specified properties and system-generated fields.

## Response

**id** `string`

Unique identifier for the ML model (UUID format).

**name** `string`

ML model name.

**fullyQualifiedName** `string`

Fully qualified name in format `service.modelName`.

**displayName** `string`

Human-readable display name.

**description** `string`

Description of the ML model in Markdown format.

**algorithm** `string`

Algorithm used by the ML model.

**mlFeatures** `array`

Features used by the ML model.

**properties**

**name** `string`

Name of the feature.

**dataType** `string`

Data type of the feature.

**featureSources** `array`

Sources of the feature data.

**mlHyperParameters** `array`

Hyperparameters used by the ML model.

**properties**

**name** `string`

Name of the hyperparameter.

**value** `string`

Value of the hyperparameter.

**target** `string`

Target variable or objective of the ML model.

**service** `object`

Reference to the parent ML model service.

**properties**

**id** `string`

UUID of the ML model service.

**type** `string`

Type of entity (always `mlmodelService`).

**name** `string`

Name of the ML model service.

**fullyQualifiedName** `string`

Fully qualified name of the ML model service.

**serviceType** `string`

Type of ML model service, for example Mlflow, Sklearn, SageMaker.

**owners** `array`

List of owners assigned to the ML model.

**properties**

**id** `string`

UUID of the owner entity.

**type** `string`

Type of owner entity, for example `user`, `team`.

**name** `string`

Name of the owner entity.

**domains** `array`

Domain assignments for governance.

**tags** `array`

Classification tags applied to the ML model.

**properties**

**tagFQN** `string`

Fully qualified name of the tag.

**labelType** `string`

Type of label, for example `Manual`, `Derived`, `Propagated`.

**state** `string`

State of the tag, for example `Suggested`, `Confirmed`.

**extension** `object`

Custom property values defined by your organization's metadata schema.

**version** `number`

Version number for the entity (starts at 0.1).

***

## Create or Update (PUT)

Use `PUT /v1/mlmodels` instead of `POST` to perform an upsert. If an ML model with the same `fullyQualifiedName` already exists, it will be updated; otherwise, a new ML model is created. The request body is the same as `POST`.

```bash theme={null}
curl -X PUT "{base_url}/api/v1/mlmodels" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{ ... same body as POST ... }'
```

> [!NOTE]
>
> `PUT` will not return a `409` conflict error if the entity already exists -- it will update the existing entity instead.

***

## Bulk Create or Update (PUT)

Use `PUT /v1/mlmodels/bulk` to create or update multiple ML models in a single request. The request body is an array of create request objects.

```bash theme={null}
curl -X PUT "{base_url}/api/v1/mlmodels/bulk" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '[
    { "name": "model_one", "service": "mlflow_svc", "algorithm": "KMeans" },
    { "name": "model_two", "service": "mlflow_svc", "algorithm": "RandomForest" }
  ]'
```

***

## Error Handling

| Code | Error Type | Description |
| - | - | - |
| `400` | `BAD_REQUEST` | Invalid request body or missing required fields |
| `401` | `UNAUTHORIZED` | Invalid or missing authentication token |
| `403` | `FORBIDDEN` | User lacks permission to create ML models |
| `409` | `ENTITY_ALREADY_EXISTS` | ML model with same name already exists in service (POST only) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.