Perform inference on the service Added in 8.11.0
This API enables you to use machine learning models to perform specific tasks on data that you provide as an input. It returns a response with the results of the tasks. The inference endpoint you use can perform one specific task that has been defined when the endpoint was created with the create inference API.
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.
Path parameters
-
The unique identifier for the inference endpoint.
Query parameters
-
timeout string
The amount of time to wait for the inference request to complete.
Body
-
query string
The query input, which is required only for the
rerank
task. It is not required for other tasks. input string | array[string] Required
The text on which you want to perform the inference task. It can be a single string or an array.
Inference endpoints for the
completion
task type currently only support a single string as input.-
task_settings object
Additional properties are allowed.
curl \
--request POST http://api.example.com/_inference/{inference_id} \
--header "Content-Type: application/json" \
--data '{"query":"string","input":"string","task_settings":{}}'
{
"query": "string",
"input": "string",
"task_settings": {}
}
{
"text_embedding_bytes": [
{
"embedding": [
42.0
]
}
],
"text_embedding_bits": [
{
"embedding": [
42.0
]
}
],
"text_embedding": [
{
"embedding": [
42.0
]
}
],
"sparse_embedding": [
{
"embedding": {
"additionalProperty1": 42.0,
"additionalProperty2": 42.0
}
}
],
"completion": [
{
"result": "string"
}
],
"rerank": [
{
"index": 42.0,
"relevance_score": 42.0,
"text": "string"
}
]
}