class PromptVariant
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Bedrock.Alpha.PromptVariant |
Go | github.com/aws/aws-cdk-go/awsbedrockalpha/v2#PromptVariant |
Java | software.amazon.awscdk.services.bedrock.alpha.PromptVariant |
Python | aws_cdk.aws_bedrock_alpha.PromptVariant |
TypeScript (source) | @aws-cdk/aws-bedrock-alpha ยป PromptVariant |
Factory class for creating prompt variants.
Provides static methods to create different types of prompt variants with proper configuration and type safety.
Example
const cmk = new kms.Key(this, 'cmk', {});
const claudeModel = bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_SONNET_V1_0;
const variant1 = bedrock.PromptVariant.text({
variantName: 'variant1',
model: claudeModel,
promptVariables: ['topic'],
promptText: 'This is my first text prompt. Please summarize our conversation on: {{topic}}.',
inferenceConfiguration: bedrock.PromptInferenceConfiguration.text({
temperature: 1.0,
topP: 0.999,
maxTokens: 2000,
}),
});
const prompt1 = new bedrock.Prompt(this, 'prompt1', {
promptName: 'prompt1',
description: 'my first prompt',
defaultVariant: variant1,
variants: [variant1],
kmsKey: cmk,
});
Methods
| Name | Description |
|---|---|
| static agent(props) | Creates an agent prompt template variant. |
| static chat(props) | Creates a chat template variant. |
| static text(props) | Creates a text template variant. |
static agent(props)
public static agent(props: AgentPromptVariantProps): IPromptVariant
Parameters
- props
Agentโ - Properties for the agent prompt variant.Prompt Variant Props
Returns
Creates an agent prompt template variant.
static chat(props)
public static chat(props: ChatPromptVariantProps): IPromptVariant
Parameters
- props
Chatโ - Properties for the chat prompt variant.Prompt Variant Props
Returns
Creates a chat template variant.
Use this template type when the model supports the Converse API or the Anthropic Claude Messages API. This allows you to include a System prompt and previous User messages and Assistant messages for context.
static text(props)
public static text(props: TextPromptVariantProps): IPromptVariant
Parameters
- props
Textโ - Properties for the text prompt variant.Prompt Variant Props
Returns
Creates a text template variant.

.NET
Go
Java
Python
TypeScript (