400 Bad request while trying to invoke a model in Mendix Studio Pro

1
Hi Team, I downloaded the 'Amazon Bedrock Example Implementation' module from the Mendix marketplace. After entering the input prompt and selecting 'ai21.j2-mid' from the active model drop-down, I attempted to invoke the model but received the following response. Please let me know if I have configured something incorrectly. Note: I generated access key credentials from my AWS account, and I have also obtained access to the specific model. In the attached image, I created an object for credentials entity and updated the provider as static, along with the access and secret access keys from the AWS console.         ModelID: ‘ai21.j2-mid’ RequestBody: {"prompt":"Write an engaging product description for a clothing eCommerce site. Make sure to include the following features in the description. \nProduct: Humor Men's Graphic T-Shirt. \nFeatures: \n- Soft cotton \n- Short sleeve\n- Have a print of Einstein's quote: \"artificial intelligence is no match for natural stupidity” \nDescription: ","maxTokens":200,"temperature":0.5,"topP":0.5,"stopSequences":[],"countPenalty":{"scale":0,"applyToWhitespaces":false,"applyToNumbers":false,"applyToEmojis":false,"applyToPunctuations":false,"applyToStopwords":false},"presencePenalty":{"scale":0,"applyToWhitespaces":false,"applyToNumbers":false,"applyToEmojis":false,"applyToPunctuations":false,"applyToStopwords":false},"frequencyPenalty":{"scale":0,"applyToWhitespaces":false,"applyToNumbers":false,"applyToEmojis":false,"applyToPunctuations":false,"applyToStopwords":false}}   Error log: 400: Bad Request at AmazonBedrockConnector.POST_V1_InvokeModel_Generic (CallRest : 'Call REST (POST)') at ExampleImplementation.InvokeModelRequestAI21LabsJurassic_GetResponse (SubMicroflow : 'Invoke Model Generic') at ExampleImplementation.InvokeModelRequestAI21LabsJurassic_GenericAction (SubMicroflow : 'InvokeModelRequestAI21LabsJurassic_GetResponse') at ExampleImplementation.Prompt_InvokeModel (SubMicroflow : 'InvokeModelRequestAI21LabsJurassic_GenericAction') at ExampleImplementation.ACT_InvokeModel (SubMicroflow : 'Prompt_InvokeModel') Advanced stacktrace:    
asked
6 answers
0

Hi Sathish,

 

I'm just touching base regarding your query about the Amazon Bedrock integration.

 

Were you able to implement the Amazon Bedrock Connector successfully with the latest release? If you've had a chance to try it out, we'd love to hear about your experience, whether it was smooth sailing or if you hit a snag somewhere along the line.

 

If you're still encountering any issues, or if you have further questions, please don't hesitate to reach out. 

 

Best,

Trong

answered
0

Hi Sathish Kumar,

 

I'm Trong from the team that has developed the Amazon Bedrock Connector.

 

Firstly, I'd like to express my appreciation for sharing your issue in such detailed manner. Your contribution could be invaluable to others who might encounter similar challenges.

 

Upon a thorough examination of the provided error logs and details, I believe the root of the issue might stem from the accessibility of the model you're trying to invoke via the API. The nature of the "400: Bad Request" error, combined with the message that the "requested operation is not recognized by the service," leads me to think that your credential set and/or AWS organization might not have the necessary permissions or access to the specific model you're attempting to invoke.

 

To address this, I suggest you navigate to the Amazon Bedrock Model Access section within the Amazon Bedrock environment. In this section, you should see an overview of the available models and their respective accessibility status concerning your AWS organization. The status you're looking for should read Access Granted. If you notice a status that indicates "Available" instead, it would mean that the model is available, but not yet accessible by your credentials. You can enable access by following these steps:

  1. In the top-right corner of the overview, click on Edit.
  2. A checkbox should appear next to each model. Select the models you wish to access with your credential set by checking the appropriate boxes.
  3. Once you've made your selections, navigate to the bottom-right corner and click Save Changes.

 

Be advised that the process of being granted access can take up to 10 minutes, after which the status should display as Access Granted.

 

I hope this helps!

 

Best,

Trong

answered
0

Dear Sathish Kumar,

 

These credentials might not have the permissions for the API actions associated with Amazon Bedrock.

 

To put this hypothesis to the test, I suggest crafting a new set of credentials that solely have the rights requisite for the example implementation.

 

Here is a step-by-step on how to generate a fresh set of credentials:

  • Access the AWS Console:
    Ensure you're logging in using an account with administrative rights, either the root user account of your AWS organization or an IAM user possessing the administrative rights to create IAM users and IAM policies.
  • Navigate to IAM:
    Proceed to the 'Identity and Access Management' (IAM) section.
  • Create an IAM Policy:
    On the left side menu, select  "Policies".
    On the upper right side, click on "Create Policy".
    Switch to JSON mode by selecting "JSON" on the top-right corner.
    Integrate the JSON snippet attached at the end of this message.
    Proceed by clicking "Next".
    Designate a name for this policy, for instance, "BedrockExampleImplementation".
    Conclude by selecting "Create Policy". Upon successful execution, a message "Policy BedrockExampleImplementation created" should appear.
  • Attach the IAM Policy to a New User:
    In the left menu, select "Users".
    Click on "Create User" located at the top right.
    Assign a name, for example, "BedrockExampleImplementation", and advance to the next stage.
    Under "Permission Options", select "Attach policies directly".
    Search for the policy you named earlier.
    Subsequent to attaching the policy, finalize the creation of the user.
  • Generate Access Key:
    Within the 'Users' section, locate and select the newly created IAM user.
    Shift from the 'Permissions' tab to the 'Security credentials' tab.
    In the “Access key” section, click "Create access key" in the top-right.
    For the Use case, select "Other".
    You have the option to associate tags to your access key.
    Conclude the creation of the access key. "Access key created" should appear.
    It's of imperative to securely store the access key and secret access key details. After clicking “Done”, retrieving the secret access key will not be possible.

    I invite you to use these generated credentials and observe if the issue persists. Should there be further complications or clarifications required, please do not hesitate to reach out.

 

JSON snippet:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:ListFoundationModels"
            ],
            "Resource": "*"
        }
    ]
}

 

This IAM policy will allow the IAM user to invoke the API actions ListFoundationModels and InvokeModel that are associated with Amazon Bedrock and are crucial in making the Example Implementation operable.

 

Best,

Trong

answered
0

Hi Sathish,

 

I've engaged my team to conduct an investigation into this issue. We recently encountered a similar situation. In that scenario, an AWS organization, not affiliated to us, was capable of listing the foundation models via the ListFoundationModels action, but subsequently encountered errors invoking the returned models. To better understand this, a member from our team set up a private AWS account, granted access to AI21's models, and created a new IAM user with the specific permission to invoke Amazon Bedrock's API. Unfortunately, the results mirror your experience, as we faced a 400 Bad Request with the same message: "The requested operation is not recognized by the service."

 

From our comprehensive examination, testing, and the reproducibility of this issue, we have drawn a preliminary conclusion. It appears that the root cause might be attributed to the Amazon Bedrock service itself rather than a misconfiguration on our end or yours. We are engaging with AWS directly to share (y)our findings and to seek a way forward.

 

For your records and as an additional tool for diagnosis, I've attached a JSON snippet at the end of this message, only omitting our AWS credentials. This snippet represents a Postman collection, comprising of a HTTP POST request as recreated by the information you have provided. Notably, this has been found to function seamlessly with our credentials, assumingly because those that had been previously granted preview access to Amazon Bedrock.

 

{ "info": { "_postman_id": "9969a71b-9427-4ad2-8242-d97f2b7be89e", "name": "Amazon Bedrock", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "25022662" }, "item": [ { "name": "Oregon (us-west-2)", "protocolProfileBehavior": { "disabledSystemHeaders": { "content-type": true } }, "request": { "auth": { "type": "awsv4", "awsv4": [ { "key": "accessKey", "value": "", "type": "string" }, { "key": "secretKey", "value": "", "type": "string" }, { "key": "region", "value": "us-west-2", "type": "string" }, { "key": "service", "value": "bedrock", "type": "string" }, { "key": "addAuthDataToQuery", "value": false, "type": "boolean" }, { "key": "sessionToken", "value": "", "type": "string" } ] }, "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\"prompt\":\"Write an engaging product description for a clothing eCommerce site. Make sure to include the following features in the description. \\nProduct: Humor Men's Graphic T-Shirt. \\nFeatures: \\n- Soft cotton \\n- Short sleeve\\n- Have a print of Einstein's quote: \\\"artificial intelligence is no match for natural stupidity” \\nDescription: \",\"maxTokens\":200,\"temperature\":0.5,\"topP\":0.5,\"stopSequences\":[],\"countPenalty\":{\"scale\":0,\"applyToWhitespaces\":false,\"applyToNumbers\":false,\"applyToEmojis\":false,\"applyToPunctuations\":false,\"applyToStopwords\":false},\"presencePenalty\":{\"scale\":0,\"applyToWhitespaces\":false,\"applyToNumbers\":false,\"applyToEmojis\":false,\"applyToPunctuations\":false,\"applyToStopwords\":false},\"frequencyPenalty\":{\"scale\":0,\"applyToWhitespaces\":false,\"applyToNumbers\":false,\"applyToEmojis\":false,\"applyToPunctuations\":false,\"applyToStopwords\":false}}" }, "url": { "raw": "https://bedrock.us-west-2.amazonaws.com/model/ai21.j2-mid/invoke", "protocol": "https", "host": [ "bedrock", "us-west-2", "amazonaws", "com" ], "path": [ "model", "ai21.j2-mid", "invoke" ] } }, "response": [] } ], "auth": { "type": "awsv4", "awsv4": [ { "key": "service", "value": "", "type": "string" }, { "key": "region", "value": "", "type": "string" }, { "key": "secretKey", "value": "", "type": "string" }, { "key": "accessKey", "value": "", "type": "string" } ] }, "event": [ { "listen": "prerequest", "script": { "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "type": "text/javascript", "exec": [ "" ] } } ] }

Rest assured, we will continue to collaborate with AWS on this matter.

 

Best,

Trong

answered
0

Hello Sathish,

 

I wanted to inform you that we were able to identify the root cause of the problem. The error that you faced is linked to the invocation endpoint. The endpoint had changed after Amazon Bedrock became generally available, effectively invalidating the Amazon Bedrock Connector. Our team acknowledges this and is actively working on releasing an updated version of the Amazon Bedrock Connector to address this and ensure it invokes the correct endpoints.

 

To receive a notification when we release this new iteration you can hit the "Save and Get Notified" button on the marketplace listing.

 

Best,

Trong

answered
0

Hi Trong,

 

Thanks for the update. After downloading the new release I could able to get the successful response and the models are working fine as expected.

 

Thanks and Regards,

Sathish Kumar

answered