---
type: api
title: Clear trained model deployment cache
description: Cache will be cleared on all nodes where the trained model is assigned.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-clear-trained-model-deployment-cache
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-clear-trained-model-deployment-cache
products:
  - Elasticsearch
---

# Clear trained model deployment cache

Availability: 8.5+

## Paths

- `POST` `/_ml/trained_models/{model_id}/deployment/cache/_clear`

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

#### Path Parameters

- `model_id` (string Id)
  The unique identifier of the trained model.

## Description

Cache will be cleared on all nodes where the trained model is assigned.
A trained model deployment may have an inference cache enabled.
As requests are handled by each allocated node, their responses may be cached on that individual node.
Calling this API clears the caches without restarting the deployment.

## Required authorization

* Cluster privileges: `manage_ml`

## Response

`application/json`

- `cleared` (boolean)
## Code Examples

#### Console

```console
POST _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/cache/_clear
```

#### JavaScript

```javascript
const response = await client.ml.clearTrainedModelDeploymentCache({
  model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english",
});
```

#### Python

```python
resp = client.ml.clear_trained_model_deployment_cache(
    model_id="elastic__distilbert-base-uncased-finetuned-conll03-english",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/cache/_clear" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().clearTrainedModelDeploymentCache(c -> c
    .modelId("elastic__distilbert-base-uncased-finetuned-conll03-english")
);
```

#### C#

```c#
var response = await client.MachineLearning.ClearTrainedModelDeploymentCacheAsync(modelId: "elastic__distilbert-base-uncased-finetuned-conll03-english");
```

#### PHP

```php
$resp = $client->ml()->clearTrainedModelDeploymentCache([
    "model_id" => "elastic__distilbert-base-uncased-finetuned-conll03-english",
]);
```

#### Ruby

```ruby
response = client.ml.clear_trained_model_deployment_cache(
  model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english"
)
```

## Response Examples

#### Ml clear trained model deployment cache response example1

A successful response when clearing the inference cache.

```json
{
  "cleared": true
}
```

