Get inference API

Get inference API

New API reference

For the most up-to-date API details, refer to Inference APIs.

Retrieves inference endpoint information.

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.

Request

GET /_inference

GET /_inference/_all

GET /_inference/<inference_id>

GET /_inference/<task_type>/_all

GET /_inference/<task_type>/<inference_id>

Prerequisites

  • Requires the monitor_inference cluster privilege (the built-in inference_admin and inference_user roles grant this privilege)

Description

You can get information in a single API request for:

  • a single inference endpoint by providing the task type and the inference ID,
  • all of the inference endpoints for a certain task type by providing the task type and a wildcard expression,
  • all of the inference endpoints by using a wildcard expression.

Path parameters

<inference_id>

(Optional, string) The unique identifier of the inference endpoint.

<task_type>

(Optional, string) The type of inference task that the model performs.

Examples

The following API call retrieves information about the my-elser-model inference model that can perform sparse_embedding tasks.

  1. resp = client.inference.get(
  2. task_type="sparse_embedding",
  3. inference_id="my-elser-model",
  4. )
  5. print(resp)
  1. response = client.inference.get_model(
  2. task_type: 'sparse_embedding',
  3. inference_id: 'my-elser-model'
  4. )
  5. puts response
  1. const response = await client.inference.get({
  2. task_type: "sparse_embedding",
  3. inference_id: "my-elser-model",
  4. });
  5. console.log(response);
  1. GET _inference/sparse_embedding/my-elser-model

The API returns the following response:

  1. {
  2. "inference_id": "my-elser-model",
  3. "task_type": "sparse_embedding",
  4. "service": "elasticsearch",
  5. "service_settings": {
  6. "num_allocations": 1,
  7. "num_threads": 1,
  8. "model_id": ".elser_model_2"
  9. },
  10. "chunking_settings": {
  11. "strategy": "sentence",
  12. "max_chunk_size": 250,
  13. "sentence_overlap": 1
  14. }
  15. }