java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IEnvironmentAware, IResource, IPrompt, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.127.0 (build 2117ad5)", date="2026-04-02T21:55:35.462Z") @Stability(Experimental) public class Prompt extends PromptBase implements IPrompt
(experimental) Class to create (or import) a Prompt with CDK.

Prompts are a specific set of inputs that guide Foundation Models (FMs) on Amazon Bedrock to generate an appropriate response or output for a given task or instruction. You can optimize the prompt for specific use cases and models.

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();
 

See Also:
  • Field Details

    • PROPERTY_INJECTION_ID

      @Stability(Experimental) public static final String PROPERTY_INJECTION_ID
      (experimental) Uniquely identifies this class.
  • Constructor Details

    • Prompt

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

      protected Prompt(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Prompt

      @Stability(Experimental) public Prompt(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull PromptProps props)
      (experimental) **************************************************************************** CONSTRUCTOR ***************************************************************************.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromPromptAttributes

      @Stability(Experimental) @NotNull public static IPrompt fromPromptAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull PromptAttributes attrs)
      (experimental) Creates a Prompt reference from an existing prompt's attributes.

      Default: - For attrs.promptVersion: 'DRAFT' if no explicit version is provided

      Parameters:
      scope -
      • The construct scope.
      This parameter is required.
      id -
      • Identifier of the construct.
      This parameter is required.
      attrs -
      • Attributes of the existing prompt.
      This parameter is required.
      Returns:
      An IPrompt reference to the existing prompt
    • addVariant

      @Stability(Experimental) public void addVariant(@NotNull IPromptVariant variant)
      (experimental) Adds a prompt variant to the prompt.

      Parameters:
      variant -
      • The prompt variant to add.
      This parameter is required.
    • createVersion

      @Stability(Experimental) @NotNull public PromptVersion createVersion(@Nullable String description)
      (experimental) Creates a prompt version, a static snapshot of your prompt that can be deployed to production.

      Default: - No description provided

      Parameters:
      description -
      • Optional description for the version.
      Returns:
      A PromptVersion object containing the version details including ARN and version string
    • createVersion

      @Stability(Experimental) @NotNull public PromptVersion createVersion()
      (experimental) Creates a prompt version, a static snapshot of your prompt that can be deployed to production.

      Default: - No description provided

      Returns:
      A PromptVersion object containing the version details including ARN and version string
    • getPromptArn

      @Stability(Experimental) @NotNull public String getPromptArn()
      (experimental) The ARN of the prompt.

      Example:

       "arn:aws:bedrock:us-east-1:123456789012:prompt/PROMPT12345";
       
      Specified by:
      getPromptArn in interface IPrompt
      Specified by:
      getPromptArn in class PromptBase
    • getPromptId

      @Stability(Experimental) @NotNull public String getPromptId()
      (experimental) The ID of the prompt.

      Example:

       "PROMPT12345";
       
      Specified by:
      getPromptId in interface IPrompt
      Specified by:
      getPromptId in class PromptBase
    • getPromptName

      @Stability(Experimental) @NotNull public String getPromptName()
      (experimental) The name of the prompt.
    • getPromptVersion

      @Stability(Experimental) @NotNull public String getPromptVersion()
      (experimental) The version of the prompt.
      Specified by:
      getPromptVersion in interface IPrompt
      Specified by:
      getPromptVersion in class PromptBase
    • getVariants

      @Stability(Experimental) @NotNull public List<IPromptVariant> getVariants()
      (experimental) The variants of the prompt.
    • getDescription

      @Stability(Experimental) @Nullable public String getDescription()
      (experimental) The description of the prompt.
    • getKmsKey

      @Stability(Experimental) @Nullable public IKey getKmsKey()
      (experimental) The KMS key that the prompt is encrypted with.
      Specified by:
      getKmsKey in interface IPrompt
      Specified by:
      getKmsKey in class PromptBase