Interface SageMakerRuntimeAsyncClient

All Superinterfaces:
AutoCloseable, AwsClient, SdkAutoCloseable, SdkClient

@Generated("software.amazon.awssdk:codegen") @ThreadSafe public interface SageMakerRuntimeAsyncClient extends AwsClient
Service client for accessing Amazon SageMaker Runtime asynchronously. This can be created using the static builder() method.The asynchronous client performs non-blocking I/O when configured with any
invalid reference
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 runtime API.

  • Field Details

  • Method Details

    • invokeEndpoint

      default CompletableFuture<InvokeEndpointResponse> invokeEndpoint(InvokeEndpointRequest invokeEndpointRequest)

      After you deploy a model into production using Amazon SageMaker hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint.

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

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

      Calls to InvokeEndpoint 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.

      A customer's model containers must respond to requests within 60 seconds. The model itself can have a maximum processing time of 60 seconds before responding to invocations. If your model is going to take 50-60 seconds of processing time, the SDK socket timeout should be set to be 70 seconds.

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

      Parameters:
      invokeEndpointRequest -
      Returns:
      A Java Future containing the result of the InvokeEndpoint operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.
      • InternalFailureException An internal failure occurred.
      • ServiceUnavailableException The service is unavailable. Try your call again.
      • ValidationErrorException Inspect your request and try again.
      • ModelErrorException Model (owned by the customer in the container) returned 4xx or 5xx error code.
      • InternalDependencyException Your request caused an exception with an internal dependency. Contact customer support.
      • ModelNotReadyException Either a serverless endpoint variant's resources are still being provisioned, or a multi-model endpoint is still downloading or loading the target model. Wait and try your request again.
      • 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.
      • SageMakerRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • invokeEndpoint

      default CompletableFuture<InvokeEndpointResponse> invokeEndpoint(Consumer<InvokeEndpointRequest.Builder> invokeEndpointRequest)

      After you deploy a model into production using Amazon SageMaker hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint.

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

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

      Calls to InvokeEndpoint 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.

      A customer's model containers must respond to requests within 60 seconds. The model itself can have a maximum processing time of 60 seconds before responding to invocations. If your model is going to take 50-60 seconds of processing time, the SDK socket timeout should be set to be 70 seconds.

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


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

      Parameters:
      invokeEndpointRequest - A Consumer that will call methods on InvokeEndpointRequest.Builder to create a request.
      Returns:
      A Java Future containing the result of the InvokeEndpoint operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.
      • InternalFailureException An internal failure occurred.
      • ServiceUnavailableException The service is unavailable. Try your call again.
      • ValidationErrorException Inspect your request and try again.
      • ModelErrorException Model (owned by the customer in the container) returned 4xx or 5xx error code.
      • InternalDependencyException Your request caused an exception with an internal dependency. Contact customer support.
      • ModelNotReadyException Either a serverless endpoint variant's resources are still being provisioned, or a multi-model endpoint is still downloading or loading the target model. Wait and try your request again.
      • 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.
      • SageMakerRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • invokeEndpointAsync

      default CompletableFuture<InvokeEndpointAsyncResponse> invokeEndpointAsync(InvokeEndpointAsyncRequest invokeEndpointAsyncRequest)

      After you deploy a model into production using Amazon SageMaker hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint in an asynchronous manner.

      Inference requests sent to this API are enqueued for asynchronous processing. The processing of the inference request may or may not complete before you receive a response from this API. The response from this API will not contain the result of the inference request but contain information about where you can locate it.

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

      Calls to InvokeEndpointAsync 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.

      Parameters:
      invokeEndpointAsyncRequest -
      Returns:
      A Java Future containing the result of the InvokeEndpointAsync operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.
      • InternalFailureException An internal failure occurred.
      • ServiceUnavailableException The service is unavailable. Try your call again.
      • ValidationErrorException Inspect your request and try again.
      • 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.
      • SageMakerRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • invokeEndpointAsync

      default CompletableFuture<InvokeEndpointAsyncResponse> invokeEndpointAsync(Consumer<InvokeEndpointAsyncRequest.Builder> invokeEndpointAsyncRequest)

      After you deploy a model into production using Amazon SageMaker hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint in an asynchronous manner.

      Inference requests sent to this API are enqueued for asynchronous processing. The processing of the inference request may or may not complete before you receive a response from this API. The response from this API will not contain the result of the inference request but contain information about where you can locate it.

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

      Calls to InvokeEndpointAsync 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.


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

      Parameters:
      invokeEndpointAsyncRequest - A Consumer that will call methods on InvokeEndpointAsyncRequest.Builder to create a request.
      Returns:
      A Java Future containing the result of the InvokeEndpointAsync operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.
      • InternalFailureException An internal failure occurred.
      • ServiceUnavailableException The service is unavailable. Try your call again.
      • ValidationErrorException Inspect your request and try again.
      • 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.
      • SageMakerRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • invokeEndpointWithResponseStream

      default CompletableFuture<Void> invokeEndpointWithResponseStream(InvokeEndpointWithResponseStreamRequest invokeEndpointWithResponseStreamRequest, InvokeEndpointWithResponseStreamResponseHandler asyncResponseHandler)

      Invokes a model at the specified endpoint to return the inference response as a stream. The inference stream provides the response payload incrementally as a series of parts. Before you can get an inference stream, you must have access to a model that's deployed using Amazon SageMaker hosting services, and the container for that model must support inference streaming.

      For more information that can help you use this API, see the following sections in the Amazon SageMaker Developer Guide:

      Before you can use this operation, your IAM permissions must allow the sagemaker:InvokeEndpoint action. For more information about Amazon SageMaker actions for IAM policies, see Actions, resources, and condition keys for Amazon SageMaker in the IAM Service Authorization Reference.

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

      Calls to InvokeEndpointWithResponseStream 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.

      Parameters:
      invokeEndpointWithResponseStreamRequest -
      Returns:
      A Java Future containing the result of the InvokeEndpointWithResponseStream operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.
      • InternalFailureException An internal failure occurred.
      • ServiceUnavailableException The service is unavailable. Try your call again.
      • ValidationErrorException Inspect your request and try again.
      • ModelErrorException Model (owned by the customer in the container) returned 4xx or 5xx error code.
      • ModelStreamErrorException An error occurred while streaming the response body. This error can have the following error codes:

        ModelInvocationTimeExceeded

        The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker.

        StreamBroken

        The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.

      • InternalStreamFailureException The stream processing failed because of an unknown error, exception or failure. Try your request again.
      • 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.
      • SageMakerRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • invokeEndpointWithResponseStream

      default CompletableFuture<Void> invokeEndpointWithResponseStream(Consumer<InvokeEndpointWithResponseStreamRequest.Builder> invokeEndpointWithResponseStreamRequest, InvokeEndpointWithResponseStreamResponseHandler asyncResponseHandler)

      Invokes a model at the specified endpoint to return the inference response as a stream. The inference stream provides the response payload incrementally as a series of parts. Before you can get an inference stream, you must have access to a model that's deployed using Amazon SageMaker hosting services, and the container for that model must support inference streaming.

      For more information that can help you use this API, see the following sections in the Amazon SageMaker Developer Guide:

      Before you can use this operation, your IAM permissions must allow the sagemaker:InvokeEndpoint action. For more information about Amazon SageMaker actions for IAM policies, see Actions, resources, and condition keys for Amazon SageMaker in the IAM Service Authorization Reference.

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

      Calls to InvokeEndpointWithResponseStream 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.


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

      Parameters:
      invokeEndpointWithResponseStreamRequest - A Consumer that will call methods on InvokeEndpointWithResponseStreamRequest.Builder to create a request.
      Returns:
      A Java Future containing the result of the InvokeEndpointWithResponseStream operation returned by the service.
      The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.
      • InternalFailureException An internal failure occurred.
      • ServiceUnavailableException The service is unavailable. Try your call again.
      • ValidationErrorException Inspect your request and try again.
      • ModelErrorException Model (owned by the customer in the container) returned 4xx or 5xx error code.
      • ModelStreamErrorException An error occurred while streaming the response body. This error can have the following error codes:

        ModelInvocationTimeExceeded

        The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker.

        StreamBroken

        The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.

      • InternalStreamFailureException The stream processing failed because of an unknown error, exception or failure. Try your request again.
      • 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.
      • SageMakerRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
      See Also:
    • serviceClientConfiguration

      default SageMakerRuntimeServiceClientConfiguration 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

      static SageMakerRuntimeAsyncClient create()
      Create a SageMakerRuntimeAsyncClient 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 SageMakerRuntimeAsyncClient.