All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Bedrock Runtime module holds the client classes that are used for communicating with Bedrock Runtime.

There is a newer version: 2.30.1
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.bedrockruntime;

import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.awscore.AwsClient;
import software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest;
import software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailResponse;
import software.amazon.awssdk.services.bedrockruntime.model.ConverseRequest;
import software.amazon.awssdk.services.bedrockruntime.model.ConverseResponse;
import software.amazon.awssdk.services.bedrockruntime.model.ConverseStreamRequest;
import software.amazon.awssdk.services.bedrockruntime.model.ConverseStreamResponseHandler;
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest;
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse;
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelWithResponseStreamRequest;
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelWithResponseStreamResponseHandler;

/**
 * Service client for accessing Amazon Bedrock Runtime asynchronously. This can be created using the static
 * {@link #builder()} method.The asynchronous client performs non-blocking I/O when configured with any
 * {@code 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.
 *
 * 

* Describes the API operations for running inference using Amazon Bedrock models. *

*/ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi @ThreadSafe public interface BedrockRuntimeAsyncClient extends AwsClient { String SERVICE_NAME = "bedrock"; /** * Value for looking up the service's metadata from the * {@link software.amazon.awssdk.regions.ServiceMetadataProvider}. */ String SERVICE_METADATA_ID = "bedrock-runtime"; /** *

* The action to apply a guardrail. *

* * @param applyGuardrailRequest * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ValidationException Input validation failed. Check your request parameters and retry the request.
  • *
  • ServiceQuotaExceededException Your request exceeds the service quota for your account. You can view * your quotas at Viewing service * quotas. You can 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.
  • *
* @sample BedrockRuntimeAsyncClient.ApplyGuardrail * @see AWS API Documentation */ default CompletableFuture applyGuardrail(ApplyGuardrailRequest applyGuardrailRequest) { throw new UnsupportedOperationException(); } /** *

* The action to apply a guardrail. *

*
*

* This is a convenience which creates an instance of the {@link ApplyGuardrailRequest.Builder} avoiding the need to * create one manually via {@link ApplyGuardrailRequest#builder()} *

* * @param applyGuardrailRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.bedrockruntime.model.ApplyGuardrailRequest.Builder} to create a * request. * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ValidationException Input validation failed. Check your request parameters and retry the request.
  • *
  • ServiceQuotaExceededException Your request exceeds the service quota for your account. You can view * your quotas at Viewing service * quotas. You can 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.
  • *
* @sample BedrockRuntimeAsyncClient.ApplyGuardrail * @see AWS API Documentation */ default CompletableFuture applyGuardrail(Consumer applyGuardrailRequest) { return applyGuardrail(ApplyGuardrailRequest.builder().applyMutation(applyGuardrailRequest).build()); } /** *

* Sends messages to the specified Amazon Bedrock model. Converse provides a consistent interface that * works with all models that support messages. This allows you to write code once and use it with different models. * If a model has unique inference parameters, you can also pass those unique parameters to the model. *

*

* Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to * generate 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 Converse API examples in the Amazon Bedrock User Guide. *

*

* This operation requires permission for the bedrock:InvokeModel action. *

* * @param converseRequest * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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.
  • *
* @sample BedrockRuntimeAsyncClient.Converse * @see AWS API * Documentation */ default CompletableFuture converse(ConverseRequest converseRequest) { throw new UnsupportedOperationException(); } /** *

* Sends messages to the specified Amazon Bedrock model. Converse provides a consistent interface that * works with all models that support messages. This allows you to write code once and use it with different models. * If a model has unique inference parameters, you can also pass those unique parameters to the model. *

*

* Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to * generate 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 Converse API examples in the Amazon Bedrock User Guide. *

*

* This operation requires permission for the bedrock:InvokeModel action. *

*
*

* This is a convenience which creates an instance of the {@link ConverseRequest.Builder} avoiding the need to * create one manually via {@link ConverseRequest#builder()} *

* * @param converseRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.bedrockruntime.model.ConverseRequest.Builder} to create a request. * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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.
  • *
* @sample BedrockRuntimeAsyncClient.Converse * @see AWS API * Documentation */ default CompletableFuture converse(Consumer converseRequest) { return converse(ConverseRequest.builder().applyMutation(converseRequest).build()); } /** *

* Sends messages to the specified Amazon Bedrock model and returns the response in a stream. * ConverseStream provides 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 responseStreamingSupported field in the response. *

* *

* The CLI doesn't support streaming operations in Amazon Bedrock, including ConverseStream. *

*
*

* Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to * generate 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:InvokeModelWithResponseStream action. *

* * @param converseStreamRequest * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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.
  • *
* @sample BedrockRuntimeAsyncClient.ConverseStream * @see AWS API Documentation */ default CompletableFuture converseStream(ConverseStreamRequest converseStreamRequest, ConverseStreamResponseHandler asyncResponseHandler) { throw new UnsupportedOperationException(); } /** *

* Sends messages to the specified Amazon Bedrock model and returns the response in a stream. * ConverseStream provides 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 responseStreamingSupported field in the response. *

* *

* The CLI doesn't support streaming operations in Amazon Bedrock, including ConverseStream. *

*
*

* Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to * generate 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:InvokeModelWithResponseStream action. *

*
*

* This is a convenience which creates an instance of the {@link ConverseStreamRequest.Builder} avoiding the need to * create one manually via {@link ConverseStreamRequest#builder()} *

* * @param converseStreamRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.bedrockruntime.model.ConverseStreamRequest.Builder} to create a * request. * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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.
  • *
* @sample BedrockRuntimeAsyncClient.ConverseStream * @see AWS API Documentation */ default CompletableFuture converseStream(Consumer converseStreamRequest, ConverseStreamResponseHandler asyncResponseHandler) { return converseStream(ConverseStreamRequest.builder().applyMutation(converseStreamRequest).build(), asyncResponseHandler); } /** *

* 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:InvokeModel action. *

* * @param invokeModelRequest * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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 Your request exceeds the service quota for your account. You can view * your quotas at Viewing service * quotas. You can 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.
  • *
* @sample BedrockRuntimeAsyncClient.InvokeModel * @see AWS * API Documentation */ default CompletableFuture invokeModel(InvokeModelRequest invokeModelRequest) { throw new UnsupportedOperationException(); } /** *

* 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:InvokeModel action. *

*
*

* This is a convenience which creates an instance of the {@link InvokeModelRequest.Builder} avoiding the need to * create one manually via {@link InvokeModelRequest#builder()} *

* * @param invokeModelRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest.Builder} to create a * request. * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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 Your request exceeds the service quota for your account. You can view * your quotas at Viewing service * quotas. You can 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.
  • *
* @sample BedrockRuntimeAsyncClient.InvokeModel * @see AWS * API Documentation */ default CompletableFuture invokeModel(Consumer invokeModelRequest) { return invokeModel(InvokeModelRequest.builder().applyMutation(invokeModelRequest).build()); } /** *

* 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 responseStreamingSupported field in the response. *

* *

* The CLI doesn't support streaming operations in Amazon Bedrock, including * 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:InvokeModelWithResponseStream action. *

* * @param invokeModelWithResponseStreamRequest * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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 Your request exceeds the service quota for your account. You can view * your quotas at Viewing service * quotas. You can 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.
  • *
* @sample BedrockRuntimeAsyncClient.InvokeModelWithResponseStream * @see AWS API Documentation */ default CompletableFuture invokeModelWithResponseStream( InvokeModelWithResponseStreamRequest invokeModelWithResponseStreamRequest, InvokeModelWithResponseStreamResponseHandler asyncResponseHandler) { throw new UnsupportedOperationException(); } /** *

* 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 responseStreamingSupported field in the response. *

* *

* The CLI doesn't support streaming operations in Amazon Bedrock, including * 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:InvokeModelWithResponseStream action. *

*
*

* This is a convenience which creates an instance of the {@link InvokeModelWithResponseStreamRequest.Builder} * avoiding the need to create one manually via {@link InvokeModelWithResponseStreamRequest#builder()} *

* * @param invokeModelWithResponseStreamRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.bedrockruntime.model.InvokeModelWithResponseStreamRequest.Builder} * to create a request. * @return 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 invoke * {@link Throwable#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 Your request was throttled because of service-wide limitations. Resubmit your * request later or in a different region. You can also purchase Provisioned * Throughput to increase the rate or number of tokens you can process.
  • *
  • ModelTimeoutException The request took too long to process. Processing time exceeded the model * timeout length.
  • *
  • InternalServerException An internal server error occurred. Retry your request.
  • *
  • ServiceUnavailableException The service isn't currently available. Try again later.
  • *
  • 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 Your request exceeds the service quota for your account. You can view * your quotas at Viewing service * quotas. You can 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.
  • *
* @sample BedrockRuntimeAsyncClient.InvokeModelWithResponseStream * @see AWS API Documentation */ default CompletableFuture invokeModelWithResponseStream( Consumer invokeModelWithResponseStreamRequest, InvokeModelWithResponseStreamResponseHandler asyncResponseHandler) { return invokeModelWithResponseStream( InvokeModelWithResponseStreamRequest.builder().applyMutation(invokeModelWithResponseStreamRequest).build(), asyncResponseHandler); } @Override default BedrockRuntimeServiceClientConfiguration serviceClientConfiguration() { throw new UnsupportedOperationException(); } /** * Create a {@link BedrockRuntimeAsyncClient} with the region loaded from the * {@link software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain} and credentials loaded from the * {@link software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider}. */ static BedrockRuntimeAsyncClient create() { return builder().build(); } /** * Create a builder that can be used to configure and create a {@link BedrockRuntimeAsyncClient}. */ static BedrockRuntimeAsyncClientBuilder builder() { return new DefaultBedrockRuntimeAsyncClientBuilder(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy