---
type: api
title: Create part of a trained model definition
description: ## Required authorization
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-ml-put-trained-model-definition-part
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-ml-put-trained-model-definition-part
products:
  - Elasticsearch
---

# Create part of a trained model definition

Availability: 8.0+

## Paths

- `PUT` `/_ml/trained_models/{model_id}/definition/{part}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `model_id` (string Id)
  The unique identifier of the trained model.
- `part` (number)
  The definition part number. When the definition is loaded for inference the definition parts are streamed in the
order of their part number. The first part must be `0` and the final part must be `total_parts - 1`.

## Description



## Required authorization

* Cluster privileges: `manage_ml`

## Request Body

`application/json`

- `definition` (string) — required
  The definition part for the model. Must be a base64 encoded string.
- `total_definition_length` (number) — required
  The total uncompressed definition length in bytes. Not base64 encoded.
- `total_parts` (number) — required
  The total number of parts that will be uploaded. Must be greater than 0.

## Response

`application/json`

- `acknowledged` (boolean)
  For a successful response, this value is always true. On failure, an exception is returned instead.
## Code Examples

#### Console

```console
PUT _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/definition/0
{
    "definition": "...",
    "total_definition_length": 265632637,
    "total_parts": 64
}
```

#### JavaScript

```javascript
const response = await client.ml.putTrainedModelDefinitionPart({
  model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english",
  part: 0,
  definition: "...",
  total_definition_length: 265632637,
  total_parts: 64,
});
```

#### Python

```python
resp = client.ml.put_trained_model_definition_part(
    model_id="elastic__distilbert-base-uncased-finetuned-conll03-english",
    part="0",
    definition="...",
    total_definition_length=265632637,
    total_parts=64,
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/definition/0" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "definition": "...",
    "total_definition_length": 265632637,
    "total_parts": 64
  }'
```

#### C#

```c#
var response = await client.MachineLearning
    .PutTrainedModelDefinitionPartAsync(modelId: "elastic__distilbert-base-uncased-finetuned-conll03-english", part: 0, d1 => d1
        .Definition("...")
        .TotalDefinitionLength(265632637L)
        .TotalParts(64)
    );
```

#### PHP

```php
$resp = $client->ml()->putTrainedModelDefinitionPart([
    "model_id" => "elastic__distilbert-base-uncased-finetuned-conll03-english",
    "part" => "0",
    "body" => [
        "definition" => "...",
        "total_definition_length" => 265632637,
        "total_parts" => 64,
    ],
]);
```

#### Ruby

```ruby
response = client.ml.put_trained_model_definition_part(
  model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english",
  part: "0",
  body: {
    "definition": "...",
    "total_definition_length": 265632637,
    "total_parts": 64
  }
)
```

