
co.elastic.clients.elasticsearch.inference.ElasticsearchInferenceAsyncClient Maven / Gradle / Ivy
Show all versions of org.apache.servicemix.bundles.elasticsearch-java
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.clients.elasticsearch.inference;
import co.elastic.clients.ApiClient;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.Endpoint;
import co.elastic.clients.transport.JsonEndpoint;
import co.elastic.clients.transport.Transport;
import co.elastic.clients.transport.TransportOptions;
import co.elastic.clients.transport.endpoints.BinaryResponse;
import co.elastic.clients.util.ObjectBuilder;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import javax.annotation.Nullable;
//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------
/**
* Client for the inference namespace.
*/
public class ElasticsearchInferenceAsyncClient
extends
ApiClient {
public ElasticsearchInferenceAsyncClient(ElasticsearchTransport transport) {
super(transport, null);
}
public ElasticsearchInferenceAsyncClient(ElasticsearchTransport transport,
@Nullable TransportOptions transportOptions) {
super(transport, transportOptions);
}
@Override
public ElasticsearchInferenceAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) {
return new ElasticsearchInferenceAsyncClient(this.transport, transportOptions);
}
// ----- Endpoint: inference.chat_completion_unified
/**
* Perform chat completion inference
*
* The chat completion inference API enables real-time responses for chat
* completion tasks by delivering answers incrementally, reducing response times
* during computation. It only works with the chat_completion
task
* type for openai
and elastic
inference services.
*
* NOTE: The chat_completion
task type is only available within the
* _stream API and only supports streaming. The Chat completion inference API
* and the Stream inference API differ in their response structure and
* capabilities. The Chat completion inference API provides more comprehensive
* customization options through more fields and function calling support. If
* you use the openai
service or the elastic
service,
* use the Chat completion inference API.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture chatCompletionUnified(ChatCompletionUnifiedRequest request) {
@SuppressWarnings("unchecked")
Endpoint endpoint = (Endpoint) ChatCompletionUnifiedRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Perform chat completion inference
*
* The chat completion inference API enables real-time responses for chat
* completion tasks by delivering answers incrementally, reducing response times
* during computation. It only works with the chat_completion
task
* type for openai
and elastic
inference services.
*
* NOTE: The chat_completion
task type is only available within the
* _stream API and only supports streaming. The Chat completion inference API
* and the Stream inference API differ in their response structure and
* capabilities. The Chat completion inference API provides more comprehensive
* customization options through more fields and function calling support. If
* you use the openai
service or the elastic
service,
* use the Chat completion inference API.
*
* @param fn
* a function that initializes a builder to create the
* {@link ChatCompletionUnifiedRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture chatCompletionUnified(
Function> fn) {
return chatCompletionUnified(fn.apply(new ChatCompletionUnifiedRequest.Builder()).build());
}
// ----- Endpoint: inference.completion
/**
* Perform completion inference on the service
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture completion(CompletionRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) CompletionRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Perform completion inference on the service
*
* @param fn
* a function that initializes a builder to create the
* {@link CompletionRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture completion(
Function> fn) {
return completion(fn.apply(new CompletionRequest.Builder()).build());
}
// ----- Endpoint: inference.delete
/**
* Delete an inference endpoint
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture delete(DeleteInferenceRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) DeleteInferenceRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Delete an inference endpoint
*
* @param fn
* a function that initializes a builder to create the
* {@link DeleteInferenceRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture delete(
Function> fn) {
return delete(fn.apply(new DeleteInferenceRequest.Builder()).build());
}
// ----- Endpoint: inference.get
/**
* Get an inference endpoint
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture get(GetInferenceRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) GetInferenceRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Get an inference endpoint
*
* @param fn
* a function that initializes a builder to create the
* {@link GetInferenceRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture get(
Function> fn) {
return get(fn.apply(new GetInferenceRequest.Builder()).build());
}
/**
* Get an inference endpoint
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture get() {
return this.transport.performRequestAsync(new GetInferenceRequest.Builder().build(),
GetInferenceRequest._ENDPOINT, this.transportOptions);
}
// ----- Endpoint: inference.inference
/**
* 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.
*
* For details about using this API with a service, such as Amazon Bedrock,
* Anthropic, or HuggingFace, refer to the service-specific documentation.
*
*
* 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.
*
*
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture inference(InferenceRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) InferenceRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* 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.
*
* For details about using this API with a service, such as Amazon Bedrock,
* Anthropic, or HuggingFace, refer to the service-specific documentation.
*
*
* 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.
*
*
*
* @param fn
* a function that initializes a builder to create the
* {@link InferenceRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture inference(
Function> fn) {
return inference(fn.apply(new InferenceRequest.Builder()).build());
}
// ----- Endpoint: inference.put
/**
* Create an inference endpoint.
*
* 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.
*
* The following integrations are available through the inference API. You can
* find the available task types next to the integration name:
*
* - AlibabaCloud AI Search (
completion
, rerank
,
* sparse_embedding
, text_embedding
)
* - Amazon Bedrock (
completion
,
* text_embedding
)
* - Anthropic (
completion
)
* - Azure AI Studio (
completion
,
* text_embedding
)
* - Azure OpenAI (
completion
, text_embedding
)
* - Cohere (
completion
, rerank
,
* text_embedding
)
* - Elasticsearch (
rerank
, sparse_embedding
,
* text_embedding
- this service is for built-in models and models
* uploaded through Eland)
* - ELSER (
sparse_embedding
)
* - Google AI Studio (
completion
,
* text_embedding
)
* - Google Vertex AI (
rerank
, text_embedding
)
* - Hugging Face (
text_embedding
)
* - Mistral (
text_embedding
)
* - OpenAI (
chat_completion
, completion
,
* text_embedding
)
* - VoyageAI (
text_embedding
, rerank
)
* - Watsonx inference integration (
text_embedding
)
* - JinaAI (
text_embedding
, rerank
)
*
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture put(PutRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an inference endpoint.
*
* 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.
*
* The following integrations are available through the inference API. You can
* find the available task types next to the integration name:
*
* - AlibabaCloud AI Search (
completion
, rerank
,
* sparse_embedding
, text_embedding
)
* - Amazon Bedrock (
completion
,
* text_embedding
)
* - Anthropic (
completion
)
* - Azure AI Studio (
completion
,
* text_embedding
)
* - Azure OpenAI (
completion
, text_embedding
)
* - Cohere (
completion
, rerank
,
* text_embedding
)
* - Elasticsearch (
rerank
, sparse_embedding
,
* text_embedding
- this service is for built-in models and models
* uploaded through Eland)
* - ELSER (
sparse_embedding
)
* - Google AI Studio (
completion
,
* text_embedding
)
* - Google Vertex AI (
rerank
, text_embedding
)
* - Hugging Face (
text_embedding
)
* - Mistral (
text_embedding
)
* - OpenAI (
chat_completion
, completion
,
* text_embedding
)
* - VoyageAI (
text_embedding
, rerank
)
* - Watsonx inference integration (
text_embedding
)
* - JinaAI (
text_embedding
, rerank
)
*
*
* @param fn
* a function that initializes a builder to create the
* {@link PutRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture put(Function> fn) {
return put(fn.apply(new PutRequest.Builder()).build());
}
// ----- Endpoint: inference.put_alibabacloud
/**
* Create an AlibabaCloud AI Search inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* alibabacloud-ai-search
service.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putAlibabacloud(PutAlibabacloudRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutAlibabacloudRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an AlibabaCloud AI Search inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* alibabacloud-ai-search
service.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutAlibabacloudRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putAlibabacloud(
Function> fn) {
return putAlibabacloud(fn.apply(new PutAlibabacloudRequest.Builder()).build());
}
// ----- Endpoint: inference.put_amazonbedrock
/**
* Create an Amazon Bedrock inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* amazonbedrock
service.
*
* info You need to provide the access and secret keys only once, during the
* inference model creation. The get inference API does not retrieve your access
* or secret keys. After creating the inference model, you cannot change the
* associated key pairs. If you want to use a different access and secret key
* pair, delete the inference model and recreate it with the same name and the
* updated keys.
*
*
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putAmazonbedrock(PutAmazonbedrockRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutAmazonbedrockRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an Amazon Bedrock inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* amazonbedrock
service.
*
* info You need to provide the access and secret keys only once, during the
* inference model creation. The get inference API does not retrieve your access
* or secret keys. After creating the inference model, you cannot change the
* associated key pairs. If you want to use a different access and secret key
* pair, delete the inference model and recreate it with the same name and the
* updated keys.
*
*
*
* @param fn
* a function that initializes a builder to create the
* {@link PutAmazonbedrockRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putAmazonbedrock(
Function> fn) {
return putAmazonbedrock(fn.apply(new PutAmazonbedrockRequest.Builder()).build());
}
// ----- Endpoint: inference.put_anthropic
/**
* Create an Anthropic inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* anthropic
service.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putAnthropic(PutAnthropicRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutAnthropicRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an Anthropic inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* anthropic
service.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutAnthropicRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putAnthropic(
Function> fn) {
return putAnthropic(fn.apply(new PutAnthropicRequest.Builder()).build());
}
// ----- Endpoint: inference.put_azureaistudio
/**
* Create an Azure AI studio inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* azureaistudio
service.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putAzureaistudio(PutAzureaistudioRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutAzureaistudioRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an Azure AI studio inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* azureaistudio
service.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutAzureaistudioRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putAzureaistudio(
Function> fn) {
return putAzureaistudio(fn.apply(new PutAzureaistudioRequest.Builder()).build());
}
// ----- Endpoint: inference.put_azureopenai
/**
* Create an Azure OpenAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* azureopenai
service.
*
* The list of chat completion models that you can choose from in your Azure
* OpenAI deployment include:
*
*
* The list of embeddings models that you can choose from in your deployment can
* be found in the Azure
* models documentation.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putAzureopenai(PutAzureopenaiRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutAzureopenaiRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an Azure OpenAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* azureopenai
service.
*
* The list of chat completion models that you can choose from in your Azure
* OpenAI deployment include:
*
*
* The list of embeddings models that you can choose from in your deployment can
* be found in the Azure
* models documentation.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutAzureopenaiRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putAzureopenai(
Function> fn) {
return putAzureopenai(fn.apply(new PutAzureopenaiRequest.Builder()).build());
}
// ----- Endpoint: inference.put_cohere
/**
* Create a Cohere inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* cohere
service.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putCohere(PutCohereRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutCohereRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create a Cohere inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* cohere
service.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutCohereRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putCohere(
Function> fn) {
return putCohere(fn.apply(new PutCohereRequest.Builder()).build());
}
// ----- Endpoint: inference.put_elasticsearch
/**
* Create an Elasticsearch inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* elasticsearch
service.
*
* info Your Elasticsearch deployment contains preconfigured ELSER and E5
* inference endpoints, you only need to create the enpoints using the API if
* you want to customize the settings.
*
*
*
* If you use the ELSER or the E5 model through the elasticsearch
* service, the API request will automatically download and deploy the model if
* it isn't downloaded yet.
*
* info You might see a 502 bad gateway error in the response when using the
* Kibana Console. This error usually just reflects a timeout, while the model
* downloads in the background. You can check the download progress in the
* Machine Learning UI. If using the Python client, you can set the timeout
* parameter to a higher value.
*
*
*
* 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.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putElasticsearch(PutElasticsearchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutElasticsearchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an Elasticsearch inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* elasticsearch
service.
*
* info Your Elasticsearch deployment contains preconfigured ELSER and E5
* inference endpoints, you only need to create the enpoints using the API if
* you want to customize the settings.
*
*
*
* If you use the ELSER or the E5 model through the elasticsearch
* service, the API request will automatically download and deploy the model if
* it isn't downloaded yet.
*
* info You might see a 502 bad gateway error in the response when using the
* Kibana Console. This error usually just reflects a timeout, while the model
* downloads in the background. You can check the download progress in the
* Machine Learning UI. If using the Python client, you can set the timeout
* parameter to a higher value.
*
*
*
* 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.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutElasticsearchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putElasticsearch(
Function> fn) {
return putElasticsearch(fn.apply(new PutElasticsearchRequest.Builder()).build());
}
// ----- Endpoint: inference.put_elser
/**
* Create an ELSER inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* elser
service. You can also deploy ELSER by using the
* Elasticsearch inference integration.
*
* info Your Elasticsearch deployment contains a preconfigured ELSER inference
* endpoint, you only need to create the enpoint using the API if you want to
* customize the settings.
*
*
*
* The API request will automatically download and deploy the ELSER model if it
* isn't already downloaded.
*
* info You might see a 502 bad gateway error in the response when using the
* Kibana Console. This error usually just reflects a timeout, while the model
* downloads in the background. You can check the download progress in the
* Machine Learning UI. If using the Python client, you can set the timeout
* parameter to a higher value.
*
*
*
* 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.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putElser(PutElserRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutElserRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an ELSER inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* elser
service. You can also deploy ELSER by using the
* Elasticsearch inference integration.
*
* info Your Elasticsearch deployment contains a preconfigured ELSER inference
* endpoint, you only need to create the enpoint using the API if you want to
* customize the settings.
*
*
*
* The API request will automatically download and deploy the ELSER model if it
* isn't already downloaded.
*
* info You might see a 502 bad gateway error in the response when using the
* Kibana Console. This error usually just reflects a timeout, while the model
* downloads in the background. You can check the download progress in the
* Machine Learning UI. If using the Python client, you can set the timeout
* parameter to a higher value.
*
*
*
* 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.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutElserRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putElser(
Function> fn) {
return putElser(fn.apply(new PutElserRequest.Builder()).build());
}
// ----- Endpoint: inference.put_googleaistudio
/**
* Create an Google AI Studio inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* googleaistudio
service.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putGoogleaistudio(PutGoogleaistudioRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutGoogleaistudioRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an Google AI Studio inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* googleaistudio
service.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutGoogleaistudioRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putGoogleaistudio(
Function> fn) {
return putGoogleaistudio(fn.apply(new PutGoogleaistudioRequest.Builder()).build());
}
// ----- Endpoint: inference.put_googlevertexai
/**
* Create a Google Vertex AI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* googlevertexai
service.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putGooglevertexai(PutGooglevertexaiRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutGooglevertexaiRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create a Google Vertex AI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* googlevertexai
service.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutGooglevertexaiRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putGooglevertexai(
Function> fn) {
return putGooglevertexai(fn.apply(new PutGooglevertexaiRequest.Builder()).build());
}
// ----- Endpoint: inference.put_hugging_face
/**
* Create a Hugging Face inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* hugging_face
service.
*
* You must first create an inference endpoint on the Hugging Face endpoint page
* to get an endpoint URL. Select the model you want to use on the new endpoint
* creation page (for example intfloat/e5-small-v2
), then select
* the sentence embeddings task under the advanced configuration section. Create
* the endpoint and copy the URL after the endpoint initialization has been
* finished.
*
* The following models are recommended for the Hugging Face service:
*
* all-MiniLM-L6-v2
* all-MiniLM-L12-v2
* all-mpnet-base-v2
* e5-base-v2
* e5-small-v2
* multilingual-e5-base
* multilingual-e5-small
*
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putHuggingFace(PutHuggingFaceRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutHuggingFaceRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create a Hugging Face inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* hugging_face
service.
*
* You must first create an inference endpoint on the Hugging Face endpoint page
* to get an endpoint URL. Select the model you want to use on the new endpoint
* creation page (for example intfloat/e5-small-v2
), then select
* the sentence embeddings task under the advanced configuration section. Create
* the endpoint and copy the URL after the endpoint initialization has been
* finished.
*
* The following models are recommended for the Hugging Face service:
*
* all-MiniLM-L6-v2
* all-MiniLM-L12-v2
* all-mpnet-base-v2
* e5-base-v2
* e5-small-v2
* multilingual-e5-base
* multilingual-e5-small
*
*
* @param fn
* a function that initializes a builder to create the
* {@link PutHuggingFaceRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putHuggingFace(
Function> fn) {
return putHuggingFace(fn.apply(new PutHuggingFaceRequest.Builder()).build());
}
// ----- Endpoint: inference.put_jinaai
/**
* Create an JinaAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* jinaai
service.
*
* To review the available rerank
models, refer to
* https://jina.ai/reranker. To review
* the available text_embedding
models, refer to the
* https://jina.ai/embeddings/.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putJinaai(PutJinaaiRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutJinaaiRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an JinaAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* jinaai
service.
*
* To review the available rerank
models, refer to
* https://jina.ai/reranker. To review
* the available text_embedding
models, refer to the
* https://jina.ai/embeddings/.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutJinaaiRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putJinaai(
Function> fn) {
return putJinaai(fn.apply(new PutJinaaiRequest.Builder()).build());
}
// ----- Endpoint: inference.put_mistral
/**
* Create a Mistral inference endpoint.
*
* Creates an inference endpoint to perform an inference task with the
* mistral
service.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putMistral(PutMistralRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutMistralRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create a Mistral inference endpoint.
*
* Creates an inference endpoint to perform an inference task with the
* mistral
service.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutMistralRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putMistral(
Function> fn) {
return putMistral(fn.apply(new PutMistralRequest.Builder()).build());
}
// ----- Endpoint: inference.put_openai
/**
* Create an OpenAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* openai
service or openai
compatible APIs.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putOpenai(PutOpenaiRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutOpenaiRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create an OpenAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* openai
service or openai
compatible APIs.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutOpenaiRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putOpenai(
Function> fn) {
return putOpenai(fn.apply(new PutOpenaiRequest.Builder()).build());
}
// ----- Endpoint: inference.put_voyageai
/**
* Create a VoyageAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* voyageai
service.
*
* Avoid creating multiple endpoints for the same model unless required, as each
* endpoint consumes significant resources.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putVoyageai(PutVoyageaiRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutVoyageaiRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create a VoyageAI inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* voyageai
service.
*
* Avoid creating multiple endpoints for the same model unless required, as each
* endpoint consumes significant resources.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutVoyageaiRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putVoyageai(
Function> fn) {
return putVoyageai(fn.apply(new PutVoyageaiRequest.Builder()).build());
}
// ----- Endpoint: inference.put_watsonx
/**
* Create a Watsonx inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* watsonxai
service. You need an IBM Cloud Databases for
* Elasticsearch deployment to use the watsonxai
inference service.
* You can provision one through the IBM catalog, the Cloud Databases CLI
* plug-in, the Cloud Databases API, or Terraform.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putWatsonx(PutWatsonxRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutWatsonxRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Create a Watsonx inference endpoint.
*
* Create an inference endpoint to perform an inference task with the
* watsonxai
service. You need an IBM Cloud Databases for
* Elasticsearch deployment to use the watsonxai
inference service.
* You can provision one through the IBM catalog, the Cloud Databases CLI
* plug-in, the Cloud Databases API, or Terraform.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutWatsonxRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putWatsonx(
Function> fn) {
return putWatsonx(fn.apply(new PutWatsonxRequest.Builder()).build());
}
// ----- Endpoint: inference.rerank
/**
* Perform rereanking inference on the service
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture rerank(RerankRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) RerankRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Perform rereanking inference on the service
*
* @param fn
* a function that initializes a builder to create the
* {@link RerankRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture rerank(
Function> fn) {
return rerank(fn.apply(new RerankRequest.Builder()).build());
}
// ----- Endpoint: inference.sparse_embedding
/**
* Perform sparse embedding inference on the service
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture sparseEmbedding(SparseEmbeddingRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) SparseEmbeddingRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Perform sparse embedding inference on the service
*
* @param fn
* a function that initializes a builder to create the
* {@link SparseEmbeddingRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture sparseEmbedding(
Function> fn) {
return sparseEmbedding(fn.apply(new SparseEmbeddingRequest.Builder()).build());
}
// ----- Endpoint: inference.stream_completion
/**
* Perform streaming inference. Get real-time responses for completion tasks by
* delivering answers incrementally, reducing response times during computation.
* This API works only with the completion task 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.
*
* This API requires the monitor_inference
cluster privilege (the
* built-in inference_admin
and inference_user
roles
* grant this privilege). You must use a client that supports streaming.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture streamCompletion(StreamCompletionRequest request) {
@SuppressWarnings("unchecked")
Endpoint endpoint = (Endpoint) StreamCompletionRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Perform streaming inference. Get real-time responses for completion tasks by
* delivering answers incrementally, reducing response times during computation.
* This API works only with the completion task 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.
*
* This API requires the monitor_inference
cluster privilege (the
* built-in inference_admin
and inference_user
roles
* grant this privilege). You must use a client that supports streaming.
*
* @param fn
* a function that initializes a builder to create the
* {@link StreamCompletionRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture streamCompletion(
Function> fn) {
return streamCompletion(fn.apply(new StreamCompletionRequest.Builder()).build());
}
// ----- Endpoint: inference.text_embedding
/**
* Perform text embedding inference on the service
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture textEmbedding(TextEmbeddingRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) TextEmbeddingRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Perform text embedding inference on the service
*
* @param fn
* a function that initializes a builder to create the
* {@link TextEmbeddingRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture textEmbedding(
Function> fn) {
return textEmbedding(fn.apply(new TextEmbeddingRequest.Builder()).build());
}
// ----- Endpoint: inference.update
/**
* Update an inference endpoint.
*
* Modify task_settings
, secrets (within
* service_settings
), or num_allocations
for an
* inference endpoint, depending on the specific endpoint service and
* task_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.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture update(UpdateInferenceRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) UpdateInferenceRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Update an inference endpoint.
*
* Modify task_settings
, secrets (within
* service_settings
), or num_allocations
for an
* inference endpoint, depending on the specific endpoint service and
* task_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.
*
* @param fn
* a function that initializes a builder to create the
* {@link UpdateInferenceRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture update(
Function> fn) {
return update(fn.apply(new UpdateInferenceRequest.Builder()).build());
}
}