Create inference API
editCreate inference API
editCreates 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
editPUT /_inference/<task_type>/<inference_id>
Prerequisites
edit-
Requires the
manage_inference
cluster privilege (the built-ininference_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
editThe 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:
-
AlibabaCloud AI Search (
completion
,rerank
,sparse_embedding
,text_embedding
) -
Amazon Bedrock (
completion
,text_embedding
) -
Anthropic (
completion
) -
Azure AI Studio (
completion
,text_embedding
) -
Azure OpenAI (
completion
,text_embedding
) -
Cohere (
completion
,rerank
,text_embedding
) -
Elasticsearch (
rerank
,sparse_embedding
,text_embedding
- this service is for built-in models and models uploaded through Eland) -
ELSER (
sparse_embedding
) -
Google AI Studio (
completion
,text_embedding
) -
Google Vertex AI (
rerank
,text_embedding
) -
Hugging Face (
text_embedding
) -
Mistral (
text_embedding
) -
OpenAI (
completion
,text_embedding
) -
Watsonx inference service (
text_embedding
)
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
editAdaptive 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.