Create an inference endpoint
Generally available; Added in 8.11.0
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, 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.
The following integrations are available through the inference API. You can find the available task types next to the integration name:
- 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 (
chat_completion
,completion
,text_embedding
) - Mistral (
text_embedding
) - OpenAI (
chat_completion
,completion
,text_embedding
) - VoyageAI (
text_embedding
,rerank
) - Watsonx inference integration (
text_embedding
) - JinaAI (
text_embedding
,rerank
)
Required authorization
- Cluster privileges:
manage_inference
Path parameters
-
task_type
string Required The task type. Refer to the integration list in the API description for the available task types.
Values are
sparse_embedding
,text_embedding
,rerank
,completion
, orchat_completion
. -
inference_id
string Required The inference Id
Body
Required
-
chunking_settings
object -
service
string Required The service type
-
service_settings
object Required -
task_settings
object
PUT _inference/rerank/my-rerank-model
{
"service": "cohere",
"service_settings": {
"model_id": "rerank-english-v3.0",
"api_key": "{{COHERE_API_KEY}}"
}
}
curl \
--request PUT 'http://api.example.com/_inference/{task_type}/{inference_id}' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '"{\n \"service\": \"cohere\",\n \"service_settings\": {\n \"model_id\": \"rerank-english-v3.0\",\n \"api_key\": \"{{COHERE_API_KEY}}\"\n }\n}"'
{
"service": "cohere",
"service_settings": {
"model_id": "rerank-english-v3.0",
"api_key": "{{COHERE_API_KEY}}"
}
}