get-inference.asciidoc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. [role="xpack"]
  2. [[get-inference-api]]
  3. === Get {infer} API
  4. experimental[]
  5. Retrieves {infer} endpoint information.
  6. IMPORTANT: The {infer} APIs enable you to use certain services, such as built-in
  7. {ml} models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Azure or
  8. Hugging Face. For built-in models and models uploaded though Eland, the {infer}
  9. APIs offer an alternative way to use and manage trained models. However, if you
  10. do not plan to use the {infer} APIs to use these models or if you want to use
  11. non-NLP models, use the <<ml-df-trained-models-apis>>.
  12. [discrete]
  13. [[get-inference-api-request]]
  14. ==== {api-request-title}
  15. `GET /_inference`
  16. `GET /_inference/_all`
  17. `GET /_inference/<inference_id>`
  18. `GET /_inference/<task_type>/_all`
  19. `GET /_inference/<task_type>/<inference_id>`
  20. [discrete]
  21. [[get-inference-api-prereqs]]
  22. ==== {api-prereq-title}
  23. * Requires the `monitor_inference` <<privileges-list-cluster,cluster privilege>>
  24. (the built-in `inference_admin` and `inference_user` roles grant this privilege)
  25. [discrete]
  26. [[get-inference-api-desc]]
  27. ==== {api-description-title}
  28. You can get information in a single API request for:
  29. * a single {infer} endpoint by providing the task type and the {infer} ID,
  30. * all of the {infer} endpoints for a certain task type by providing the task
  31. type and a wildcard expression,
  32. * all of the {infer} endpoints by using a wildcard expression.
  33. [discrete]
  34. [[get-inference-api-path-params]]
  35. ==== {api-path-parms-title}
  36. `<inference_id>`::
  37. (Optional, string)
  38. The unique identifier of the {infer} endpoint.
  39. `<task_type>`::
  40. (Optional, string)
  41. The type of {infer} task that the model performs.
  42. [discrete]
  43. [[get-inference-api-example]]
  44. ==== {api-examples-title}
  45. The following API call retrives information about the `my-elser-model` {infer}
  46. model that can perform `sparse_embedding` tasks.
  47. [source,console]
  48. ------------------------------------------------------------
  49. GET _inference/sparse_embedding/my-elser-model
  50. ------------------------------------------------------------
  51. // TEST[skip:TBD]
  52. The API returns the following response:
  53. [source,console-result]
  54. ------------------------------------------------------------
  55. {
  56. "inference_id": "my-elser-model",
  57. "task_type": "sparse_embedding",
  58. "service": "elser",
  59. "service_settings": {
  60. "num_allocations": 1,
  61. "num_threads": 1
  62. },
  63. "task_settings": {}
  64. }
  65. ------------------------------------------------------------
  66. // NOTCONSOLE