Create inference API

edit

Creates an inference endpoint to perform an inference task.

  • The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Mistral, Azure OpenAI, 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

PUT /_inference/<task_type>/<inference_id>

Prerequisites

edit
  • Requires the manage_inference cluster privilege (the built-in inference_admin role grants this privilege)

Path parameters

edit
<inference_id>
(Required, string) The unique identifier of the inference endpoint.
<task_type>

(Required, string) The type of the inference task that the model will perform.

Refer to the service list in the API description section for the available task types.

Description

edit

The create inference API enables you to create an inference endpoint and configure a machine learning model to perform a specific inference task.

  • When creating an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
  • After creating the endpoint, wait for the model deployment to complete before using it. You can verify the deployment status by using the Get trained model statistics API. In the response, look for "state": "fully_allocated" and ensure the "allocation_count" matches the "target_allocation_count".
  • Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.

The following services are available through the inference API. You can find the available task types next to the service name. Click the links to review the configuration details of the services:

The Elasticsearch and ELSER services run on a machine learning node in your Elasticsearch cluster. The rest of the services connect to external providers.

Adaptive allocations

edit

Adaptive allocations allow inference services to dynamically adjust the number of model allocations based on the current load.

When adaptive allocations are enabled:

  • The number of allocations scales up automatically when the load increases.
  • Allocations scale down to a minimum of 0 when the load decreases, saving resources.

For more information about adaptive allocations and resources, refer to the trained model autoscaling documentation.