- Newest
- Most votes
- Most comments
When using a managed prompt with multiple variants in the Amazon Bedrock Converse API, you need to specify the exact ARN of the prompt version you want to use, which includes the variant information.
The ARN structure for a prompt version includes the variant identifier. When you create a prompt in Prompt Management, each variant gets its own unique ARN. To use a specific variant, you would use that variant's complete ARN as the modelId parameter in your Converse API call.
For example, in Python using boto3:
import boto3 bedrock = boto3.client('bedrock-runtime') response = bedrock.converse( modelId='arn:aws:bedrock:region:account-id:prompt/prompt-name/version/variant-id', promptVariables={ "variable_name": {"text": "variable_value"}, "another_variable": {"text": "another_value"} } )
Or using the AWS CLI:
aws bedrock-runtime converse \
--model-id arn:aws:bedrock:region:account-id:prompt/prompt-name/version/variant-id \
--prompt-variables '{"variable_name":{"text":"variable_value"},"another_variable":{"text":"another_value"}}'
The key is that you're not selecting a variant separately - the variant is already embedded in the ARN you use as the modelId. Each variant has its own distinct ARN that you would use to invoke that specific variant.
Sources
Amazon Bedrock Prompt Management is now available in GA | AWS Machine Learning Blog
Using Bedrock invokeModel API with prompt created in prompt management | AWS re:Post
answered 9 months ago

the specified
arn:aws:bedrock:region:account-id:prompt/prompt-name/version/variant-idformat looks suspicious as prompt arns do not even utilize the specified name, but a generated 10 character alphanumeric string instead.