Class InferenceRequest
- All Implemented Interfaces:
JsonpSerializable
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 Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class co.elastic.clients.elasticsearch._types.RequestBase
RequestBase.AbstractBuilder<BuilderT extends RequestBase.AbstractBuilder<BuilderT>>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JsonpDeserializer<InferenceRequest>
Json deserializer forInferenceRequest
static final Endpoint<InferenceRequest,
InferenceResponse, ErrorResponse> Endpoint "inference.inference
". -
Method Summary
Modifier and TypeMethodDescriptionfinal String
Required - The unique identifier for the inference endpoint.input()
Required - The text on which you want to perform the inference task.static InferenceRequest
final String
query()
The query input, which is required only for thererank
task.void
serialize
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) Serialize this object to JSON.protected void
serializeInternal
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) protected static void
final JsonData
Task settings for the individual inference request.final TaskType
taskType()
The type of inference task that the model performs.final Time
timeout()
The amount of time to wait for the inference request to complete.Methods inherited from class co.elastic.clients.elasticsearch._types.RequestBase
toString
-
Field Details
-
_DESERIALIZER
Json deserializer forInferenceRequest
-
_ENDPOINT
Endpoint "inference.inference
".
-
-
Method Details
-
of
public static InferenceRequest of(Function<InferenceRequest.Builder, ObjectBuilder<InferenceRequest>> fn) -
inferenceId
Required - The unique identifier for the inference endpoint.API name:
inference_id
-
input
Required - The text on which you want to perform the inference task. It can be a single string or an array.info Inference endpoints for the
completion
task type currently only support a single string as input.API name:
input
-
query
The query input, which is required only for thererank
task. It is not required for other tasks.API name:
query
-
taskSettings
Task settings for the individual inference request. These settings are specific to the task type you specified and override the task settings specified when initializing the service.API name:
task_settings
-
taskType
The type of inference task that the model performs.API name:
task_type
-
timeout
The amount of time to wait for the inference request to complete.API name:
timeout
-
serialize
Serialize this object to JSON.- Specified by:
serialize
in interfaceJsonpSerializable
-
serializeInternal
-
setupInferenceRequestDeserializer
protected static void setupInferenceRequestDeserializer(ObjectDeserializer<InferenceRequest.Builder> op)
-