Inference

class elasticsearch.client.InferenceClient(client)
Parameters:

client (BaseClient)

delete_model(*, inference_id, task_type=None, error_trace=None, filter_path=None, human=None, pretty=None)

Delete model in the Inference API

https://www.elastic.co/guide/en/elasticsearch/reference/8.14/delete-inference-api.html

Parameters:
  • inference_id (str) – The inference Id

  • task_type (Literal['completion', 'rerank', 'sparse_embedding', 'text_embedding'] | str | None) – The task type

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

get_model(*, inference_id, task_type=None, error_trace=None, filter_path=None, human=None, pretty=None)

Get a model in the Inference API

https://www.elastic.co/guide/en/elasticsearch/reference/8.14/get-inference-api.html

Parameters:
  • inference_id (str) – The inference Id

  • task_type (Literal['completion', 'rerank', 'sparse_embedding', 'text_embedding'] | str | None) – The task type

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

inference(*, inference_id, input=None, task_type=None, error_trace=None, filter_path=None, human=None, pretty=None, query=None, task_settings=None, timeout=None, body=None)

Perform inference on a model

https://www.elastic.co/guide/en/elasticsearch/reference/8.14/post-inference-api.html

Parameters:
  • inference_id (str) – The inference Id

  • input (str | Sequence[str] | None) – Text input to the model. Either a string or an array of strings.

  • task_type (Literal['completion', 'rerank', 'sparse_embedding', 'text_embedding'] | str | None) – The task type

  • query (str | None) – Query input, required for rerank task. Not required for other tasks.

  • task_settings (Any | None) – Optional task settings

  • timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Specifies the amount of time to wait for the inference request to complete.

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]

put_model(*, inference_id, model_config=None, body=None, task_type=None, error_trace=None, filter_path=None, human=None, pretty=None)

Configure a model for use in the Inference API

https://www.elastic.co/guide/en/elasticsearch/reference/8.14/put-inference-api.html

Parameters:
  • inference_id (str) – The inference Id

  • model_config (Mapping[str, Any] | None)

  • task_type (Literal['completion', 'rerank', 'sparse_embedding', 'text_embedding'] | str | None) – The task type

  • body (Mapping[str, Any] | None)

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]