Class PromptVariant

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.bedrock.alpha.PromptVariant
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.113.0 (build fc68b25)", date="2025-09-02T11:25:42.851Z") @Stability(Experimental) public class PromptVariant extends software.amazon.jsii.JsiiObject
(experimental) Factory class for creating prompt variants.

Provides static methods to create different types of prompt variants with proper configuration and type safety.

Example:

 Key cmk = Key.Builder.create(this, "cmk").build();
 BedrockFoundationModel claudeModel = BedrockFoundationModel.ANTHROPIC_CLAUDE_SONNET_V1_0;
 IPromptVariant variant1 = PromptVariant.text(TextPromptVariantProps.builder()
         .variantName("variant1")
         .model(claudeModel)
         .promptVariables(List.of("topic"))
         .promptText("This is my first text prompt. Please summarize our conversation on: {{topic}}.")
         .inferenceConfiguration(PromptInferenceConfiguration.text(PromptInferenceConfigurationProps.builder()
                 .temperature(1)
                 .topP(0.999)
                 .maxTokens(2000)
                 .build()))
         .build());
 Prompt prompt1 = Prompt.Builder.create(this, "prompt1")
         .promptName("prompt1")
         .description("my first prompt")
         .defaultVariant(variant1)
         .variants(List.of(variant1))
         .kmsKey(cmk)
         .build();
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    PromptVariant(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    PromptVariant(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (experimental) Creates an agent prompt template variant.
    (experimental) Creates a chat template variant.
    (experimental) Creates a text template variant.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • PromptVariant

      protected PromptVariant(software.amazon.jsii.JsiiObjectRef objRef)
    • PromptVariant

      protected PromptVariant(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
  • Method Details

    • agent

      @Stability(Experimental) @NotNull public static IPromptVariant agent(@NotNull AgentPromptVariantProps props)
      (experimental) Creates an agent prompt template variant.

      Parameters:
      props -
      • Properties for the agent prompt variant.
      This parameter is required.
      Returns:
      A PromptVariant configured for agent interactions
    • chat

      @Stability(Experimental) @NotNull public static IPromptVariant chat(@NotNull ChatPromptVariantProps props)
      (experimental) 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.

      Parameters:
      props -
      • Properties for the chat prompt variant.
      This parameter is required.
      Returns:
      A PromptVariant configured for chat interactions
    • text

      @Stability(Experimental) @NotNull public static IPromptVariant text(@NotNull TextPromptVariantProps props)
      (experimental) Creates a text template variant.

      Parameters:
      props -
      • Properties for the text prompt variant.
      This parameter is required.
      Returns:
      A PromptVariant configured for text processing