Class ElasticsearchInferenceClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Field Summary
Fields inherited from class co.elastic.clients.ApiClient
transport, transportOptions
-
Constructor Summary
ConstructorsConstructorDescriptionElasticsearchInferenceClient
(ElasticsearchTransport transport, TransportOptions transportOptions) -
Method Summary
Modifier and TypeMethodDescriptiondelete
(DeleteInferenceRequest request) Delete an inference endpointfinal DeleteInferenceResponse
Delete an inference endpointget()
Get an inference endpointget
(GetInferenceRequest request) Get an inference endpointfinal GetInferenceResponse
Get an inference endpointinference
(InferenceRequest request) Perform inference on the service.final InferenceResponse
Perform inference on the service.put
(PutRequest request) Create an inference endpoint.final PutResponse
Create an inference endpoint.update
(UpdateInferenceRequest request) Update an inference endpoint.final UpdateInferenceResponse
Update an inference endpoint.withTransportOptions
(TransportOptions transportOptions) Creates a new client with some request optionsMethods inherited from class co.elastic.clients.ApiClient
_jsonpMapper, _transport, _transportOptions, close, getDeserializer, withTransportOptions
-
Constructor Details
-
ElasticsearchInferenceClient
-
ElasticsearchInferenceClient
public ElasticsearchInferenceClient(ElasticsearchTransport transport, @Nullable TransportOptions transportOptions)
-
-
Method Details
-
withTransportOptions
public ElasticsearchInferenceClient withTransportOptions(@Nullable TransportOptions transportOptions) Description copied from class:ApiClient
Creates a new client with some request options- Specified by:
withTransportOptions
in classApiClient<ElasticsearchTransport,
ElasticsearchInferenceClient>
-
delete
public DeleteInferenceResponse delete(DeleteInferenceRequest request) throws IOException, ElasticsearchException Delete an inference endpoint- Throws:
IOException
ElasticsearchException
- See Also:
-
delete
public final DeleteInferenceResponse delete(Function<DeleteInferenceRequest.Builder, ObjectBuilder<DeleteInferenceRequest>> fn) throws IOException, ElasticsearchExceptionDelete an inference endpoint- Parameters:
fn
- a function that initializes a builder to create theDeleteInferenceRequest
- Throws:
IOException
ElasticsearchException
- See Also:
-
get
public GetInferenceResponse get(GetInferenceRequest request) throws IOException, ElasticsearchException Get an inference endpoint- Throws:
IOException
ElasticsearchException
- See Also:
-
get
public final GetInferenceResponse get(Function<GetInferenceRequest.Builder, ObjectBuilder<GetInferenceRequest>> fn) throws IOException, ElasticsearchExceptionGet an inference endpoint- Parameters:
fn
- a function that initializes a builder to create theGetInferenceRequest
- Throws:
IOException
ElasticsearchException
- See Also:
-
get
Get an inference endpoint- Throws:
IOException
ElasticsearchException
- See Also:
-
inference
public InferenceResponse inference(InferenceRequest request) throws IOException, ElasticsearchException Perform inference on the service.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.
info 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.
- Throws:
IOException
ElasticsearchException
- See Also:
-
inference
public final InferenceResponse inference(Function<InferenceRequest.Builder, ObjectBuilder<InferenceRequest>> fn) throws IOException, ElasticsearchExceptionPerform inference on the service.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.
info 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.
- Parameters:
fn
- a function that initializes a builder to create theInferenceRequest
- Throws:
IOException
ElasticsearchException
- See Also:
-
put
Create an inference endpoint. When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. After creating the endpoint, wait for the model deployment to complete before using it. To verify the deployment status, use the get trained model statistics API. Look for"state": "fully_allocated"
in the response and ensure that the"allocation_count"
matches the"target_allocation_count"
. Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Mistral, Azure OpenAI, 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.
- Throws:
IOException
ElasticsearchException
- See Also:
-
put
public final PutResponse put(Function<PutRequest.Builder, ObjectBuilder<PutRequest>> fn) throws IOException, ElasticsearchExceptionCreate an inference endpoint. When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. After creating the endpoint, wait for the model deployment to complete before using it. To verify the deployment status, use the get trained model statistics API. Look for"state": "fully_allocated"
in the response and ensure that the"allocation_count"
matches the"target_allocation_count"
. Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Mistral, Azure OpenAI, 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.
- Parameters:
fn
- a function that initializes a builder to create thePutRequest
- Throws:
IOException
ElasticsearchException
- See Also:
-
update
public UpdateInferenceResponse update(UpdateInferenceRequest request) throws IOException, ElasticsearchException Update an inference endpoint.Modify
task_settings
, secrets (withinservice_settings
), ornum_allocations
for an inference endpoint, depending on the specific endpoint service andtask_type
.IMPORTANT: 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.
- Throws:
IOException
ElasticsearchException
- See Also:
-
update
public final UpdateInferenceResponse update(Function<UpdateInferenceRequest.Builder, ObjectBuilder<UpdateInferenceRequest>> fn) throws IOException, ElasticsearchExceptionUpdate an inference endpoint.Modify
task_settings
, secrets (withinservice_settings
), ornum_allocations
for an inference endpoint, depending on the specific endpoint service andtask_type
.IMPORTANT: 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.
- Parameters:
fn
- a function that initializes a builder to create theUpdateInferenceRequest
- Throws:
IOException
ElasticsearchException
- See Also:
-