I’m trying to invoke a ML model with amazon bedrock, I verified that I used the correct credintials to connect to my AWS accout, i imported boto3, I even tried to list my S3 buckets and it worked. I also have access to this model I’m trying to use, but i keep to get the same result, what can be the problem ?
My code:
bedrock_runtime = boto3.client(
service_name="bedrock-runtime",
region_name="eu-west-3"
)
prompt="Hello"
kwargs = {
"modelId": "amazon.titan-text-express-v1",
"contentType": "application/json",
"accept": "application/json",
"body": "{"inputText":"" + prompt + "","textGenerationConfig":{"maxTokenCount":8192,"stopSequences":[],"temperature":0,"topP":1}}"
}
response = bedrock_runtime.invoke_model(**kwargs)
response
the issue:
/usr/local/lib/python3.10/dist-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
1019 )
1020 error_class = self.exceptions.from_code(error_code)
-> 1021 raise error_class(parsed_response, operation_name)
1022 else:
1023 return parsed_response
ClientError: An error occurred (UnrecognizedClientException) when calling the InvokeModel operation: The security token included in the request is invalid.
what do you recommend me to do ?