Update inference API

edit

Updates an inference endpoint.

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.

Request

edit

POST _inference/<inference_id>/_update

POST _inference/<task_type>/<inference_id>/_update

Prerequisites

edit
  • Requires the manage_inference cluster privilege (the built-in inference_admin role grants this privilege)
  • Requires an existing inference endpoint, created by using the Create inference API

Description

edit

The update inference API enables you to update the task_settings, secrets, and/or num_allocations of an existing inference endpoint.

To use the update API, you can modify task_settings, secrets (within service_settings), or num_allocations, depending on the specific endpoint service and task_type you’ve created. To view the updatable task_settings, the field names of secrets (specific to each service), and the services where num_allocations is applicable (only for the elasticsearch service), refer to the following list of services available through the inference API. You will find the available task types next to each service name. Click the links to review the service configuration details:

Path parameters

edit
<inference_id>
(Required, string) The unique identifier of the inference endpoint.
<task_type>
(Optional, string) The type of inference task that the model performs. Refer to the service list in the API description section for the available task types.

Examples

edit

The following example shows how to update an API key of an inference endpoint called my-inference-endpoint:

const response = await client.inference.inference({
  task_type: "my-inference-endpoint",
  inference_id: "_update",
  service_settings: {
    api_key: "<API_KEY>",
  },
});
console.log(response);
POST _inference/my-inference-endpoint/_update
{
 "service_settings": {
   "api_key": "<API_KEY>"
 }
}