Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Exception : Invalid Request when calling start_async_invoke [bedrock-runtime] #4382

Open
1 task
gshr opened this issue Jan 3, 2025 · 16 comments
Open
1 task
Assignees
Labels
bedrock-runtime bug This issue is a confirmed bug. p2 This is a standard priority issue service-api This issue is caused by the service API, not the SDK implementation.

Comments

@gshr
Copy link

gshr commented Jan 3, 2025

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

@gshr gshr added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Jan 3, 2025
@khushail
Copy link

Hi @gshr, thanks for reaching out.

On AWS Bedrock Runtime docs page, I found this reference article for getting validationExceptionError -
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_StartAsyncInvoke.html#API_runtime_StartAsyncInvoke_Errors

It would be helpful if you could please share the complete debug logs with us to get to the root cause. You could use this command for getting the debug logs -

boto3.set_stream_logger('')

Thanks

@khushail khushail added response-requested Waiting on additional information or feedback. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jan 28, 2025
Copy link

github-actions bot commented Feb 8, 2025

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Feb 8, 2025
@transcendentalbot
Copy link

I have the same issue. Is this resolved?

@gshr
Copy link
Author

gshr commented Feb 15, 2025

I have the same issue. Is this resolved?

No , but i believe start_async_invoke currently only support Amazon Nova Reel model .That is why i was getting above error while using with other models but not with Amazon Nova Reel .

@webideology
Copy link

webideology commented Feb 15, 2025 via email

@gshr
Copy link
Author

gshr commented Feb 15, 2025

I get the same error when trying to invoke with Nova Reel.

Has anyone been able to get Nova Reel to work?

yes i was able to get response from Nova Reel using start_async_invoke.

https://docs.aws.amazon.com/nova/latest/userguide/video-gen-code-examples.html

@github-actions github-actions bot added potential-regression Marking this issue as a potential regression to be checked by team member and removed potential-regression Marking this issue as a potential regression to be checked by team member labels Feb 16, 2025
@webideology
Copy link

webideology commented Feb 16, 2025 via email

@webideology
Copy link

webideology commented Feb 17, 2025 via email

@khushail
Copy link

I get the same error when trying to invoke with Nova Reel.
Has anyone been able to get Nova Reel to work?

yes i was able to get response from Nova Reel using start_async_invoke.

https://docs.aws.amazon.com/nova/latest/userguide/video-gen-code-examples.html

@gshr , are you able to solve the problem following the mentioned sample code?

@webideology
Copy link

I'm not. Did you see my code?

@webideology
Copy link

webideology commented Feb 18, 2025 via email

@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed response-requested Waiting on additional information or feedback. closing-soon This issue will automatically close in 4 days unless further comments are made. labels Feb 18, 2025
@khushail khushail self-assigned this Feb 18, 2025
@khushail
Copy link

@gshr, could you please help me in re-iterating the main issue here -

  1. you are trying to access the LLM using start_async_invoke
  2. this method works for Nova models as listed in this comment -Validation Exception : Invalid Request when calling start_async_invoke [bedrock-runtime] #4382 (comment)
  3. for all other models, this fails generating the "invalid request" error.

is that understanding correct ? if not, please re-iterate the main issue and if there is any other issue, please feel free to open another bug for that one.
Thanks

@khushail khushail added response-requested Waiting on additional information or feedback. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Feb 19, 2025
@webideology
Copy link

webideology commented Feb 19, 2025 via email

@gshr
Copy link
Author

gshr commented Feb 21, 2025

@gshr, could you please help me in re-iterating the main issue here -

  1. you are trying to access the LLM using start_async_invoke
  2. this method works for Nova models as listed in this comment -Validation Exception : Invalid Request when calling start_async_invoke [bedrock-runtime] #4382 (comment)
  3. for all other models, this fails generating the "invalid request" error.

is that understanding correct ? if not, please re-iterate the main issue and if there is any other issue, please feel free to open another bug for that one. Thanks

@khushail

  1. The API start_async_invoke is only working for Nova reel model (amazon.nova-reel-v1:0) other model are giving Validation Exception .
  2. Wanted to know if this behaviour is expected i.e only amazon.nova-reel-v1:0 model supports start_async_invoke

@khushail
Copy link

Thanks for clarifying there @gshr. The AWS Boto3 doc mention this pre-requisite for using start_async_invoke()-
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/start_async_invoke.html

This operation requires permission for the bedrock:InvokeModel action.

I am facing such error in using many models which I have access to. I am not able to find any doc which mentions the support for Nova model by start_async_invoke.

IMO, this looks like a Service API Issue. I will file a ticket with the team and share updates soon.

Thanks for having patience!

@khushail khushail added service-api This issue is caused by the service API, not the SDK implementation. and removed response-requested Waiting on additional information or feedback. labels Feb 21, 2025
@webideology
Copy link

webideology commented Feb 22, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bedrock-runtime bug This issue is a confirmed bug. p2 This is a standard priority issue service-api This issue is caused by the service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

4 participants