Interface BedrockRuntimeAsyncClient
-
- All Superinterfaces:
AutoCloseable,AwsClient,SdkAutoCloseable,SdkClient
@Generated("software.amazon.awssdk:codegen") @ThreadSafe public interface BedrockRuntimeAsyncClient extends AwsClient
Service client for accessing Amazon Bedrock Runtime asynchronously. This can be created using the staticbuilder()method.The asynchronous client performs non-blocking I/O when configured with anySdkAsyncHttpClientsupported 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.Describes the API operations for running inference using Amazon Bedrock models.
-
-
Field Summary
Fields Modifier and Type Field Description static StringSERVICE_METADATA_IDValue for looking up the service's metadata from theServiceMetadataProvider.static StringSERVICE_NAME
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default CompletableFuture<ApplyGuardrailResponse>applyGuardrail(Consumer<ApplyGuardrailRequest.Builder> applyGuardrailRequest)The action to apply a guardrail.default CompletableFuture<ApplyGuardrailResponse>applyGuardrail(ApplyGuardrailRequest applyGuardrailRequest)The action to apply a guardrail.static BedrockRuntimeAsyncClientBuilderbuilder()Create a builder that can be used to configure and create aBedrockRuntimeAsyncClient.default CompletableFuture<ConverseResponse>converse(Consumer<ConverseRequest.Builder> converseRequest)Sends messages to the specified Amazon Bedrock model.default CompletableFuture<ConverseResponse>converse(ConverseRequest converseRequest)Sends messages to the specified Amazon Bedrock model.default CompletableFuture<Void>converseStream(Consumer<ConverseStreamRequest.Builder> converseStreamRequest, ConverseStreamResponseHandler asyncResponseHandler)Sends messages to the specified Amazon Bedrock model and returns the response in a stream.default CompletableFuture<Void>converseStream(ConverseStreamRequest converseStreamRequest, ConverseStreamResponseHandler asyncResponseHandler)Sends messages to the specified Amazon Bedrock model and returns the response in a stream.static BedrockRuntimeAsyncClientcreate()Create aBedrockRuntimeAsyncClientwith the region loaded from theDefaultAwsRegionProviderChainand credentials loaded from theDefaultCredentialsProvider.default CompletableFuture<InvokeModelResponse>invokeModel(Consumer<InvokeModelRequest.Builder> invokeModelRequest)Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.default CompletableFuture<InvokeModelResponse>invokeModel(InvokeModelRequest invokeModelRequest)Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.default CompletableFuture<Void>invokeModelWithResponseStream(Consumer<InvokeModelWithResponseStreamRequest.Builder> invokeModelWithResponseStreamRequest, InvokeModelWithResponseStreamResponseHandler asyncResponseHandler)Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.default CompletableFuture<Void>invokeModelWithResponseStream(InvokeModelWithResponseStreamRequest invokeModelWithResponseStreamRequest, InvokeModelWithResponseStreamResponseHandler asyncResponseHandler)Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.default BedrockRuntimeServiceClientConfigurationserviceClientConfiguration()-
Methods inherited from interface software.amazon.awssdk.utils.SdkAutoCloseable
close
-
Methods inherited from interface software.amazon.awssdk.core.SdkClient
serviceName
-
-
-
-
Field Detail
-
SERVICE_NAME
static final String SERVICE_NAME
- See Also:
- Constant Field Values
-
SERVICE_METADATA_ID
static final String SERVICE_METADATA_ID
Value for looking up the service's metadata from theServiceMetadataProvider.- See Also:
- Constant Field Values
-
-
Method Detail
-
applyGuardrail
default CompletableFuture<ApplyGuardrailResponse> applyGuardrail(ApplyGuardrailRequest applyGuardrailRequest)
The action to apply a guardrail.
- Parameters:
applyGuardrailRequest-- Returns:
- A Java Future containing the result of the ApplyGuardrail 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
applyGuardrail
default CompletableFuture<ApplyGuardrailResponse> applyGuardrail(Consumer<ApplyGuardrailRequest.Builder> applyGuardrailRequest)
The action to apply a guardrail.
This is a convenience which creates an instance of the
ApplyGuardrailRequest.Builderavoiding the need to create one manually viaApplyGuardrailRequest.builder()- Parameters:
applyGuardrailRequest- AConsumerthat will call methods onApplyGuardrailRequest.Builderto create a request.- Returns:
- A Java Future containing the result of the ApplyGuardrail 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
converse
default CompletableFuture<ConverseResponse> converse(ConverseRequest converseRequest)
Sends messages to the specified Amazon Bedrock model.
Converseprovides a consistent interface that works with all models that support messages. This allows you to write code once and use it with different models. Should a model have unique inference parameters, you can also pass those unique parameters to the model.For information about the Converse API, see Use the Converse API in the Amazon Bedrock User Guide. To use a guardrail, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide. To use a tool with a model, see Tool use (Function calling) in the Amazon Bedrock User Guide
For example code, see Converse API examples in the Amazon Bedrock User Guide.
This operation requires permission for the
bedrock:InvokeModelaction.- Parameters:
converseRequest-- Returns:
- A Java Future containing the result of the Converse 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
converse
default CompletableFuture<ConverseResponse> converse(Consumer<ConverseRequest.Builder> converseRequest)
Sends messages to the specified Amazon Bedrock model.
Converseprovides a consistent interface that works with all models that support messages. This allows you to write code once and use it with different models. Should a model have unique inference parameters, you can also pass those unique parameters to the model.For information about the Converse API, see Use the Converse API in the Amazon Bedrock User Guide. To use a guardrail, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide. To use a tool with a model, see Tool use (Function calling) in the Amazon Bedrock User Guide
For example code, see Converse API examples in the Amazon Bedrock User Guide.
This operation requires permission for the
bedrock:InvokeModelaction.
This is a convenience which creates an instance of the
ConverseRequest.Builderavoiding the need to create one manually viaConverseRequest.builder()- Parameters:
converseRequest- AConsumerthat will call methods onConverseRequest.Builderto create a request.- Returns:
- A Java Future containing the result of the Converse 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
converseStream
default CompletableFuture<Void> converseStream(ConverseStreamRequest converseStreamRequest, ConverseStreamResponseHandler asyncResponseHandler)
Sends messages to the specified Amazon Bedrock model and returns the response in a stream.
ConverseStreamprovides a consistent API that works with all Amazon Bedrock models that support messages. This allows you to write code once and use it with different models. Should a model have unique inference parameters, you can also pass those unique parameters to the model.To find out if a model supports streaming, call GetFoundationModel and check the
responseStreamingSupportedfield in the response.For information about the Converse API, see Use the Converse API in the Amazon Bedrock User Guide. To use a guardrail, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide. To use a tool with a model, see Tool use (Function calling) in the Amazon Bedrock User Guide
For example code, see Conversation streaming example in the Amazon Bedrock User Guide.
This operation requires permission for the
bedrock:InvokeModelWithResponseStreamaction.- Parameters:
converseStreamRequest-- Returns:
- A Java Future containing the result of the ConverseStream 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
converseStream
default CompletableFuture<Void> converseStream(Consumer<ConverseStreamRequest.Builder> converseStreamRequest, ConverseStreamResponseHandler asyncResponseHandler)
Sends messages to the specified Amazon Bedrock model and returns the response in a stream.
ConverseStreamprovides a consistent API that works with all Amazon Bedrock models that support messages. This allows you to write code once and use it with different models. Should a model have unique inference parameters, you can also pass those unique parameters to the model.To find out if a model supports streaming, call GetFoundationModel and check the
responseStreamingSupportedfield in the response.For information about the Converse API, see Use the Converse API in the Amazon Bedrock User Guide. To use a guardrail, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide. To use a tool with a model, see Tool use (Function calling) in the Amazon Bedrock User Guide
For example code, see Conversation streaming example in the Amazon Bedrock User Guide.
This operation requires permission for the
bedrock:InvokeModelWithResponseStreamaction.
This is a convenience which creates an instance of the
ConverseStreamRequest.Builderavoiding the need to create one manually viaConverseStreamRequest.builder()- Parameters:
converseStreamRequest- AConsumerthat will call methods onConverseStreamRequest.Builderto create a request.- Returns:
- A Java Future containing the result of the ConverseStream 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
invokeModel
default CompletableFuture<InvokeModelResponse> invokeModel(InvokeModelRequest invokeModelRequest)
Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. You use model inference to generate text, images, and embeddings.
For example code, see Invoke model code examples in the Amazon Bedrock User Guide.
This operation requires permission for the
bedrock:InvokeModelaction.- Parameters:
invokeModelRequest-- Returns:
- A Java Future containing the result of the InvokeModel 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
invokeModel
default CompletableFuture<InvokeModelResponse> invokeModel(Consumer<InvokeModelRequest.Builder> invokeModelRequest)
Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. You use model inference to generate text, images, and embeddings.
For example code, see Invoke model code examples in the Amazon Bedrock User Guide.
This operation requires permission for the
bedrock:InvokeModelaction.
This is a convenience which creates an instance of the
InvokeModelRequest.Builderavoiding the need to create one manually viaInvokeModelRequest.builder()- Parameters:
invokeModelRequest- AConsumerthat will call methods onInvokeModelRequest.Builderto create a request.- Returns:
- A Java Future containing the result of the InvokeModel 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
invokeModelWithResponseStream
default CompletableFuture<Void> invokeModelWithResponseStream(InvokeModelWithResponseStreamRequest invokeModelWithResponseStreamRequest, InvokeModelWithResponseStreamResponseHandler asyncResponseHandler)
Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. The response is returned in a stream.
To see if a model supports streaming, call GetFoundationModel and check the
responseStreamingSupportedfield in the response.The CLI doesn't support
InvokeModelWithResponseStream.For example code, see Invoke model with streaming code example in the Amazon Bedrock User Guide.
This operation requires permissions to perform the
bedrock:InvokeModelWithResponseStreamaction.- Parameters:
invokeModelWithResponseStreamRequest-- Returns:
- A Java Future containing the result of the InvokeModelWithResponseStream 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ModelStreamErrorException An error occurred while streaming the response. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
invokeModelWithResponseStream
default CompletableFuture<Void> invokeModelWithResponseStream(Consumer<InvokeModelWithResponseStreamRequest.Builder> invokeModelWithResponseStreamRequest, InvokeModelWithResponseStreamResponseHandler asyncResponseHandler)
Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. The response is returned in a stream.
To see if a model supports streaming, call GetFoundationModel and check the
responseStreamingSupportedfield in the response.The CLI doesn't support
InvokeModelWithResponseStream.For example code, see Invoke model with streaming code example in the Amazon Bedrock User Guide.
This operation requires permissions to perform the
bedrock:InvokeModelWithResponseStreamaction.
This is a convenience which creates an instance of the
InvokeModelWithResponseStreamRequest.Builderavoiding the need to create one manually viaInvokeModelWithResponseStreamRequest.builder()- Parameters:
invokeModelWithResponseStreamRequest- AConsumerthat will call methods onInvokeModelWithResponseStreamRequest.Builderto create a request.- Returns:
- A Java Future containing the result of the InvokeModelWithResponseStream 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.- AccessDeniedException The request is denied because of missing access permissions.
- ResourceNotFoundException The specified resource ARN was not found. Check the ARN and try your request again.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- ModelTimeoutException The request took too long to process. Processing time exceeded the model timeout length.
- InternalServerException An internal server error occurred. Retry your request.
- ModelStreamErrorException An error occurred while streaming the response. Retry your request.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- ModelNotReadyException The model specified in the request is not ready to serve inference requests.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- ModelErrorException The request failed due to an error while processing the model.
- 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.
- BedrockRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
- AWS API Documentation
-
serviceClientConfiguration
default BedrockRuntimeServiceClientConfiguration serviceClientConfiguration()
- Specified by:
serviceClientConfigurationin interfaceAwsClient- Specified by:
serviceClientConfigurationin interfaceSdkClient
-
create
static BedrockRuntimeAsyncClient create()
Create aBedrockRuntimeAsyncClientwith the region loaded from theDefaultAwsRegionProviderChainand credentials loaded from theDefaultCredentialsProvider.
-
builder
static BedrockRuntimeAsyncClientBuilder builder()
Create a builder that can be used to configure and create aBedrockRuntimeAsyncClient.
-
-