---
type: api
title: Update an inference endpoint
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-inference-update
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-inference-update
products:
  - Elasticsearch
---

# Update an inference endpoint


Availability: 8.17+

## Paths

- `PUT` `/_inference/{task_type}/{inference_id}/_update`
- `PUT` `/_inference/{inference_id}/_update`

- [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

- `task_type` (enum TaskType) — optional, leave it out to use `/_inference/{inference_id}/_update`
  The type of inference task that the model performs.
  Values: `sparse_embedding`, `text_embedding`, `rerank`, `completion`, `chat_completion`
- `inference_id` (string Id)
  The unique identifier of the inference endpoint.

## Description

Modify `task_settings`, secrets (within `service_settings`), or `num_allocations` for an inference endpoint, depending on the specific endpoint service and `task_type`.

IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Azure, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face.
For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models.
However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs.

## Required authorization

* Cluster privileges: `manage_inference`

## Request Body

`application/json`

- `chunking_settings` ({} InferenceChunkingSettings) — optional
  Chunking configuration object
  - `max_chunk_size` (number · default: 250) — optional
    The maximum size of a chunk in words.
This value cannot be higher than `300` or lower than `20` (for `sentence` strategy) or `10` (for `word` strategy).
  - `overlap` (number · default: 100) — optional
    The number of overlapping words for chunks.
It is applicable only to a `word` chunking strategy.
This value cannot be higher than half the `max_chunk_size` value.
  - `sentence_overlap` (number · default: 1) — optional
    The number of overlapping sentences for chunks.
It is applicable only for a `sentence` chunking strategy.
It can be either `1` or `0`.
  - `strategy` (string · default: sentence) — optional
    The chunking strategy: `sentence` or `word`.
- `service` (string) — required
  The service type
- `service_settings` (ServiceSettings) — required
  Settings specific to the service
- `task_settings` (TaskSettings) — optional
  Task settings specific to the service and task type

## Response

`application/json`

- `chunking_settings` ({} InferenceChunkingSettings)
  Chunking configuration object
  - `max_chunk_size` (number · default: 250)
    The maximum size of a chunk in words.
This value cannot be higher than `300` or lower than `20` (for `sentence` strategy) or `10` (for `word` strategy).
  - `overlap` (number · default: 100)
    The number of overlapping words for chunks.
It is applicable only to a `word` chunking strategy.
This value cannot be higher than half the `max_chunk_size` value.
  - `sentence_overlap` (number · default: 1)
    The number of overlapping sentences for chunks.
It is applicable only for a `sentence` chunking strategy.
It can be either `1` or `0`.
  - `strategy` (string · default: sentence)
    The chunking strategy: `sentence` or `word`.
- `service` (string)
  The service type
- `service_settings` (ServiceSettings)
  Settings specific to the service
- `task_settings` (TaskSettings)
  Task settings specific to the service and task type
- `inference_id` (string)
  The inference Id
- `task_type` (enum TaskType)
  The task type
  Values: `sparse_embedding`, `text_embedding`, `rerank`, `completion`, `chat_completion`
## Code Examples

#### Console

```console
PUT _inference/my-inference-endpoint/_update
{
 "service_settings": {
   "api_key": "<API_KEY>"
 }
}
```

#### JavaScript

```javascript
const response = await client.inference.update({
  inference_id: "my-inference-endpoint",
  inference_config: {
    service_settings: {
      api_key: "<API_KEY>",
    },
  },
});
```

#### Python

```python
resp = client.inference.update(
    inference_id="my-inference-endpoint",
    inference_config={
        "service_settings": {
            "api_key": "<API_KEY>"
        }
    },
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_inference/my-inference-endpoint/_update" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "service_settings": {
      "api_key": "\u003CAPI_KEY\u003E"
    }
  }'
```

#### C#

```c#
var response = await client.Inference
    .UpdateAsync(new UpdateInferenceRequest()
    {
        InferenceId = "my-inference-endpoint",
        InferenceConfig = new()
        {
            Service = null,
            ServiceSettings = JsonSerializer.Deserialize<JsonElement>("""
            {
              "api_key": "\u003CAPI_KEY\u003E"
            }
            """)
        }
    });
```

#### PHP

```php
$resp = $client->inference()->update([
    "inference_id" => "my-inference-endpoint",
    "body" => [
        "service_settings" => [
            "api_key" => "<API_KEY>",
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.inference.update(
  inference_id: "my-inference-endpoint",
  body: {
    "service_settings": {
      "api_key": "<API_KEY>"
    }
  }
)
```

