boto3: Validation Exception : Invalid Request when calling start_async_invoke [bedrock-runtime]
Describe the bug
I am using boto3 to connect bedrock-runtime and invoke model mistral.mistral-small-2402-v1:0 using start_async_invoke. However , the error message occur when i execute the code
ERROR:root:Failed to start async invoke: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid
ERROR:root:An error occurred: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid
And this is my implementation:
import boto3
import json
import uuid
import logging
logging.basicConfig(level=logging.INFO)
def invoke_async(prompt: str, s3_uri: str):
try:
client = boto3.client('bedrock-runtime', region_name='us-east-1')
request_token = str(uuid.uuid4())
model_input = {
"prompt": f"<s>[INST] {prompt} [/INST]",
"max_tokens": 200
}
response = client.start_async_invoke(
clientRequestToken=request_token,
modelId="mistral.mistral-small-2402-v1:0",
modelInput=json.dumps(model_input),
outputDataConfig={
's3OutputDataConfig': {
's3Uri': s3_uri
}
}
)
print(response)
logging.info(f"Task started. Request token: {request_token}")
return request_token
except Exception as e:
logging.error(f"Failed to start async invoke: {e}")
raise
if __name__ == "__main__":
try:
invoke_async(
prompt="What is artificial intelligence?",
s3_uri="s3://bucket-name/"
)
except Exception as e:
logging.error(f"An error occurred: {e}")
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
Success Response from api
Current Behavior
INFO:botocore.credentials:Found credentials in shared credentials file: ~/.aws/credentials
ERROR:root:Failed to start async invoke: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid
ERROR:root:An error occurred: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid
Reproduction Steps
Replace s3_uri with your bucket in implementation above
Possible Solution
No response
Additional Information/Context
No response
SDK version used
1.35.91
Environment details (OS name and version, etc.)
macOS
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 32 (2 by maintainers)
Sorry for the confusion. I did not mean to say that. According to the documentation Nova Reel requires start_async_invoke. I don’t know about other models or there invocation methods. I was just trying to say that starting_async_invoke is required for nova reel.
Bennie
From: MichaelN @.> Date: Thursday, February 27, 2025 at 6:57 AM To: boto/boto3 @.> Cc: Bennie Boone @.>, Mention @.> Subject: Re: [boto/boto3] Validation Exception : Invalid Request when calling start_async_invoke [bedrock-runtime] (Issue #4382)
@webideologyhttps://github.com/webideology sorry to insist, but where exactly in the documentation does it state that StartAsyncInvoke only works for Nova Reel model? In the link you provided, there only is an example of the StartAsyncInvoke with a Nova Reel, but it does not state that it only works for this model.
By the way this issue is not related to boto3 as I am trying to make it work with other SDKs and I have the same issue.
Hi, we opened a ticket to AWS and got confirmation that this method only works with video and image models. Still no documentation provided, though…
— Reply to this email directly, view it on GitHubhttps://github.com/boto/boto3/issues/4382#issuecomment-2688208097, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5PDABFE7I7PCH5MIMA7WQT2R4RWRAVCNFSM6AAAAABURVX7AGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBYGIYDQMBZG4. You are receiving this because you were mentioned.Message ID: @.***> [Image removed by sender. MichaelNaor]MichaelNaor left a comment (boto/boto3#4382)https://github.com/boto/boto3/issues/4382#issuecomment-2688208097
@webideologyhttps://github.com/webideology sorry to insist, but where exactly in the documentation does it state that StartAsyncInvoke only works for Nova Reel model? In the link you provided, there only is an example of the StartAsyncInvoke with a Nova Reel, but it does not state that it only works for this model.
By the way this issue is not related to boto3 as I am trying to make it work with other SDKs and I have the same issue.
Hi, we opened a ticket to AWS and got confirmation that this method only works with video and image models. Still no documentation provided, though…
— Reply to this email directly, view it on GitHubhttps://github.com/boto/boto3/issues/4382#issuecomment-2688208097, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5PDABFE7I7PCH5MIMA7WQT2R4RWRAVCNFSM6AAAAABURVX7AGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBYGIYDQMBZG4. You are receiving this because you were mentioned.Message ID: @.***>
Hi, we opened a ticket to AWS and got confirmation that this method only works with video and image models. Still no documentation provided, though…
@khushail