2023-09-29 16:12:07 +08:00
[role="xpack"]
[[get-inference-api]]
=== Get {infer} API
2024-04-04 21:42:03 +08:00
Retrieves {infer} endpoint information.
2023-09-29 16:12:07 +08:00
2024-10-21 15:41:55 +08:00
IMPORTANT: The {infer} APIs enable you to use certain services, such as built-in {ml} 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 {infer} APIs offer an alternative way to use and manage trained models.
However, if you do not plan to use the {infer} APIs to use these models or if you want to use non-NLP models, use the <<ml-df-trained-models-apis>>.
2024-01-09 22:46:46 +08:00
2023-09-29 16:12:07 +08:00
[discrete]
[[get-inference-api-request]]
==== {api-request-title}
2024-04-17 00:15:59 +08:00
`GET /_inference`
2023-09-29 16:12:07 +08:00
`GET /_inference/_all`
2024-03-26 15:20:34 +08:00
`GET /_inference/<inference_id>`
2024-02-07 00:15:24 +08:00
2023-09-29 16:12:07 +08:00
`GET /_inference/<task_type>/_all`
2024-03-26 15:20:34 +08:00
`GET /_inference/<task_type>/<inference_id>`
2023-09-29 16:12:07 +08:00
[discrete]
[[get-inference-api-prereqs]]
==== {api-prereq-title}
2024-03-20 19:15:21 +08:00
* Requires the `monitor_inference` <<privileges-list-cluster,cluster privilege>>
(the built-in `inference_admin` and `inference_user` roles grant this privilege)
2023-09-29 16:12:07 +08:00
[discrete]
[[get-inference-api-desc]]
==== {api-description-title}
2023-10-17 16:58:38 +08:00
You can get information in a single API request for:
2023-09-29 16:12:07 +08:00
2024-04-04 21:42:03 +08:00
* a single {infer} endpoint by providing the task type and the {infer} ID,
* all of the {infer} endpoints for a certain task type by providing the task
type and a wildcard expression,
* all of the {infer} endpoints by using a wildcard expression.
2023-09-29 16:12:07 +08:00
[discrete]
[[get-inference-api-path-params]]
==== {api-path-parms-title}
2024-03-26 15:20:34 +08:00
`<inference_id>`::
2023-09-29 16:12:07 +08:00
(Optional, string)
2024-03-26 15:20:34 +08:00
The unique identifier of the {infer} endpoint.
2023-09-29 16:12:07 +08:00
`<task_type>`::
(Optional, string)
The type of {infer} task that the model performs.
[discrete]
[[get-inference-api-example]]
==== {api-examples-title}
2024-07-01 16:13:48 +08:00
The following API call retrieves information about the `my-elser-model` {infer}
2023-09-29 16:12:07 +08:00
model that can perform `sparse_embedding` tasks.
[source,console]
------------------------------------------------------------
GET _inference/sparse_embedding/my-elser-model
------------------------------------------------------------
// TEST[skip:TBD]
The API returns the following response:
[source,console-result]
------------------------------------------------------------
{
2024-03-26 15:20:34 +08:00
"inference_id": "my-elser-model",
2023-09-29 16:12:07 +08:00
"task_type": "sparse_embedding",
2023-10-17 16:58:38 +08:00
"service": "elser",
2023-09-29 16:12:07 +08:00
"service_settings": {
"num_allocations": 1,
"num_threads": 1
},
"task_settings": {}
}
------------------------------------------------------------
2023-10-17 16:58:38 +08:00
// NOTCONSOLE