Interface SageMakerRuntimeHttp2AsyncClient

All Superinterfaces:
AutoCloseable, AwsClient, SdkAutoCloseable, SdkClient

@Generated("software.amazon.awssdk:codegen") @SdkPublicApi @ThreadSafe public interface SageMakerRuntimeHttp2AsyncClient extends AwsClient
Service client for accessing Amazon SageMaker Runtime HTTP2 asynchronously. This can be created using the static builder() method.The asynchronous client performs non-blocking I/O when configured with any SdkAsyncHttpClient supported in the SDK. However, full non-blocking is not guaranteed as the async client may perform blocking calls in some cases such as credentials retrieval and endpoint discovery as part of the async API call.

The Amazon SageMaker AI runtime HTTP/2 API.

  • Field Details

  • Method Details

    • invokeEndpointWithBidirectionalStream

      default CompletableFuture<Void> invokeEndpointWithBidirectionalStream(InvokeEndpointWithBidirectionalStreamRequest invokeEndpointWithBidirectionalStreamRequest, org.reactivestreams.Publisher<RequestStreamEvent> requestStream, InvokeEndpointWithBidirectionalStreamResponseHandler asyncResponseHandler)

      Invokes a model endpoint with bidirectional streaming capabilities. This operation establishes a persistent connection that allows you to send multiple requests and receive streaming responses from the model in real-time.

      Bidirectional streaming is useful for interactive applications such as chatbots, real-time translation, or any scenario where you need to maintain a conversation-like interaction with the model. The connection remains open, allowing you to send additional input and receive responses without establishing a new connection for each request.

      For an overview of Amazon SageMaker AI, see How It Works.

      Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.

      Calls to InvokeEndpointWithBidirectionalStream are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.

      The bidirectional stream maintains the connection until either the client closes it or the model indicates completion. Each request and response in the stream is sent as an event with optional headers for data type and completion state.

      Endpoints are scoped to an individual account, and are not public. The URL does not contain the account ID, but Amazon SageMaker AI determines the account ID from the authentication token that is supplied by the caller.

      Parameters:
      invokeEndpointWithBidirectionalStreamRequest -
      Returns:
      A Java Future containing the result of the InvokeEndpointWithBidirectionalStream operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invoke Throwable.getCause() to retrieve the underlying exception.
      • InternalServerErrorException The request processing has failed because of an unknown error, exception or failure.
      • InputValidationErrorException The input fails to satisfy the constraints specified by an AWS service.
      • ServiceUnavailableErrorException The request has failed due to a temporary failure of the server.
      • ModelStreamErrorException Model stream error that occurs during streaming.
      • ModelErrorException An error occurred while processing the model.
      • InternalStreamFailureException Internal stream failure that occurs during streaming.
      • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
      • SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
      • SageMakerRuntimeHttp2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • invokeEndpointWithBidirectionalStream

      default CompletableFuture<Void> invokeEndpointWithBidirectionalStream(Consumer<InvokeEndpointWithBidirectionalStreamRequest.Builder> invokeEndpointWithBidirectionalStreamRequest, org.reactivestreams.Publisher<RequestStreamEvent> requestStream, InvokeEndpointWithBidirectionalStreamResponseHandler asyncResponseHandler)

      Invokes a model endpoint with bidirectional streaming capabilities. This operation establishes a persistent connection that allows you to send multiple requests and receive streaming responses from the model in real-time.

      Bidirectional streaming is useful for interactive applications such as chatbots, real-time translation, or any scenario where you need to maintain a conversation-like interaction with the model. The connection remains open, allowing you to send additional input and receive responses without establishing a new connection for each request.

      For an overview of Amazon SageMaker AI, see How It Works.

      Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.

      Calls to InvokeEndpointWithBidirectionalStream are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.

      The bidirectional stream maintains the connection until either the client closes it or the model indicates completion. Each request and response in the stream is sent as an event with optional headers for data type and completion state.

      Endpoints are scoped to an individual account, and are not public. The URL does not contain the account ID, but Amazon SageMaker AI determines the account ID from the authentication token that is supplied by the caller.


      This is a convenience which creates an instance of the InvokeEndpointWithBidirectionalStreamRequest.Builder avoiding the need to create one manually via InvokeEndpointWithBidirectionalStreamRequest.builder()

      Parameters:
      invokeEndpointWithBidirectionalStreamRequest - A Consumer that will call methods on InvokeEndpointWithBidirectionalStreamRequest.Builder to create a request.
      Returns:
      A Java Future containing the result of the InvokeEndpointWithBidirectionalStream operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invoke Throwable.getCause() to retrieve the underlying exception.
      • InternalServerErrorException The request processing has failed because of an unknown error, exception or failure.
      • InputValidationErrorException The input fails to satisfy the constraints specified by an AWS service.
      • ServiceUnavailableErrorException The request has failed due to a temporary failure of the server.
      • ModelStreamErrorException Model stream error that occurs during streaming.
      • ModelErrorException An error occurred while processing the model.
      • InternalStreamFailureException Internal stream failure that occurs during streaming.
      • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
      • SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
      • SageMakerRuntimeHttp2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • serviceClientConfiguration

      default SageMakerRuntimeHttp2ServiceClientConfiguration serviceClientConfiguration()
      Description copied from interface: SdkClient
      The SDK service client configuration exposes client settings to the user, e.g., ClientOverrideConfiguration
      Specified by:
      serviceClientConfiguration in interface AwsClient
      Specified by:
      serviceClientConfiguration in interface SdkClient
      Returns:
      SdkServiceClientConfiguration
    • create

      Create a SageMakerRuntimeHttp2AsyncClient with the region loaded from the DefaultAwsRegionProviderChain and credentials loaded from the DefaultCredentialsProvider.
    • builder

      Create a builder that can be used to configure and create a SageMakerRuntimeHttp2AsyncClient.