Interface SageMakerRuntimeHttp2AsyncClient
- All Superinterfaces:
AutoCloseable,AwsClient,SdkAutoCloseable,SdkClient
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringValue for looking up the service's metadata from theServiceMetadataProvider.static final String -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Create a builder that can be used to configure and create aSageMakerRuntimeHttp2AsyncClient.create()Create aSageMakerRuntimeHttp2AsyncClientwith the region loaded from theDefaultAwsRegionProviderChainand credentials loaded from theDefaultCredentialsProvider.default CompletableFuture<Void> invokeEndpointWithBidirectionalStream(Consumer<InvokeEndpointWithBidirectionalStreamRequest.Builder> invokeEndpointWithBidirectionalStreamRequest, org.reactivestreams.Publisher<RequestStreamEvent> requestStream, InvokeEndpointWithBidirectionalStreamResponseHandler asyncResponseHandler) Invokes a model endpoint with bidirectional streaming capabilities.default CompletableFuture<Void> invokeEndpointWithBidirectionalStream(InvokeEndpointWithBidirectionalStreamRequest invokeEndpointWithBidirectionalStreamRequest, org.reactivestreams.Publisher<RequestStreamEvent> requestStream, InvokeEndpointWithBidirectionalStreamResponseHandler asyncResponseHandler) Invokes a model endpoint with bidirectional streaming capabilities.The SDK service client configuration exposes client settings to the user, e.g., ClientOverrideConfigurationMethods inherited from interface software.amazon.awssdk.utils.SdkAutoCloseable
closeMethods inherited from interface software.amazon.awssdk.core.SdkClient
serviceName
-
Field Details
-
SERVICE_NAME
- See Also:
-
SERVICE_METADATA_ID
Value for looking up the service's metadata from theServiceMetadataProvider.- See Also:
-
-
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
InvokeEndpointWithBidirectionalStreamare 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 invokeThrowable.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
InvokeEndpointWithBidirectionalStreamare 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.Builderavoiding the need to create one manually viaInvokeEndpointWithBidirectionalStreamRequest.builder()- Parameters:
invokeEndpointWithBidirectionalStreamRequest- AConsumerthat will call methods onInvokeEndpointWithBidirectionalStreamRequest.Builderto 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 invokeThrowable.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
Description copied from interface:SdkClientThe SDK service client configuration exposes client settings to the user, e.g., ClientOverrideConfiguration- Specified by:
serviceClientConfigurationin interfaceAwsClient- Specified by:
serviceClientConfigurationin interfaceSdkClient- Returns:
- SdkServiceClientConfiguration
-
create
Create aSageMakerRuntimeHttp2AsyncClientwith the region loaded from theDefaultAwsRegionProviderChainand credentials loaded from theDefaultCredentialsProvider. -
builder
Create a builder that can be used to configure and create aSageMakerRuntimeHttp2AsyncClient.
-