invoke_model_with_bidirectional_stream
¶
invoke_model_with_bidirectional_stream(
model_id: InvokeModelIdentifier,
body: Iterator[_InvokeModelWithBidirectionalStreamInput]
| _InvokeModelWithBidirectionalStreamInput,
*,
config_overrides: Optional[BedrockRuntimeClientConfig] = None,
) -> Generator[InvokeModelWithBidirectionalStreamResponse]
Invoke the specified Amazon Bedrock model to run inference using the bidirectional stream. The response is returned in a stream that remains open for 8 minutes. A single session can contain multiple prompts and responses from the model. The prompts to the model are provided as audio files and the model's responses are spoken back to the user and transcribed.
It is possible for users to interrupt the model's response with a new prompt, which will halt the response speech. The model will retain contextual awareness of the conversation while pivoting to respond to the new prompt.
Parameters:
-
model_id(InvokeModelIdentifier) –The model ID or ARN of the model ID to use. Currently, only
amazon.nova-sonic-v1:0is supported. -
body(Iterator[_InvokeModelWithBidirectionalStreamInput] | _InvokeModelWithBidirectionalStreamInput) –The prompt and inference parameters in the format specified in the
BidirectionalInputPayloadPartin the header. You must provide the body in JSON format. To see the format and content of the request and response bodies for different models, refer to Inference parameters. For more information, see Run inference in the Bedrock User Guide.
Raises:
-
AccessDeniedException–The request is denied because you do not have sufficient permissions to perform the requested action. For troubleshooting this error, see AccessDeniedException in the Amazon Bedrock User Guide
-
InternalServerException–An internal server error occurred. For troubleshooting this error, see InternalFailure in the Amazon Bedrock User Guide
-
ModelErrorException–The request failed due to an error while processing the model.
-
ModelNotReadyException–The model specified in the request is not ready to serve inference requests. The AWS SDK will automatically retry the operation up to 5 times. For information about configuring automatic retries, see Retry behavior in the AWS SDKs and Tools reference guide.
-
ModelStreamErrorException–An error occurred while streaming the response. Retry your request.
-
ModelTimeoutException–The request took too long to process. Processing time exceeded the model timeout length.
-
ResourceNotFoundException–The specified resource ARN was not found. For troubleshooting this error, see ResourceNotFound in the Amazon Bedrock User Guide
-
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.
-
ServiceUnavailableException–The service isn't currently available. For troubleshooting this error, see ServiceUnavailable in the Amazon Bedrock User Guide
-
ThrottlingException–Your request was denied due to exceeding the account quotas for Amazon Bedrock. For troubleshooting this error, see ThrottlingException in the Amazon Bedrock User Guide
-
ValidationException–The input fails to satisfy the constraints specified by Amazon Bedrock. For troubleshooting this error, see ValidationError in the Amazon Bedrock User Guide
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_bedrock_runtime/_services/bedrock_runtime.py
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 | |