Class StreamCompletionRequest

java.lang.Object
co.elastic.clients.elasticsearch._types.RequestBase
co.elastic.clients.elasticsearch.inference.StreamCompletionRequest
All Implemented Interfaces:
JsonpSerializable

@JsonpDeserializable public class StreamCompletionRequest extends RequestBase implements JsonpSerializable
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 Also:
  • Field Details

  • Method Details

    • of

    • inferenceId

      public final String inferenceId()
      Required - The unique identifier for the inference endpoint.

      API name: inference_id

    • input

      public final List<String> input()
      Required - The text on which you want to perform the inference task. It can be a single string or an array.

      NOTE: Inference endpoints for the completion task type currently only support a single string as input.

      API name: input

    • taskSettings

      @Nullable public final JsonData 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

    • timeout

      @Nullable public final Time timeout()
      The amount of time to wait for the inference request to complete.

      API name: timeout

    • serialize

      public void serialize(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
      Serialize this object to JSON.
      Specified by:
      serialize in interface JsonpSerializable
    • serializeInternal

      protected void serializeInternal(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
    • setupStreamCompletionRequestDeserializer

      protected static void setupStreamCompletionRequestDeserializer(ObjectDeserializer<StreamCompletionRequest.Builder> op)