AWS Bedrock
Authentication
Authentication Methods
Using AWS Access Key and Secret
- Create an IAM user (or choose an existing IAM user) following these steps.
- Add required permission for this user. The following policy grants permission to invoke all model
-
- Create an access key for this user as per this doc.
- Use this access key and secret while adding the provider account to authenticate requests to the Bedrock model.
Using Assumed Role
- You can also directly specify a role that can be assumed by the service account attached to the pods running AI Gateway.
- Read more about how assumed roles work here.
Using Bedrock Guardrails
-
Create a Guardrail in AWS. More information at this link - https://aws.amazon.com/bedrock/guardrails
-
Copy the Guardrails ID and the version number
-
While calling a AWS bedrock model through TFY AI Gateway, pass the following object along with it:
-
This should ensure the response will have guardrails enforced. Consider this input where the guardrail is configured to censor PII like name, email etc.:
-
Sample output:
-
If you’re using a library like Langchain, you might have to pass the extra param in a parameter like
extra_body
as required by the library. For example, refer this Langchain OpenAI class doc.