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

@Generated(value="jsii-pacmak/1.112.0 (build de1bc80)", date="2025-07-24T11:33:25.552Z") @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:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    (experimental) A fluent builder for Prompt.

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

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.constructs.IConstruct

    software.constructs.IConstruct.Jsii$Default

    Nested classes/interfaces inherited from interface software.amazon.awscdk.services.bedrock.alpha.IPrompt

    IPrompt.Jsii$Default, IPrompt.Jsii$Proxy

    Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource

    IResource.Jsii$Default
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    (experimental) Uniquely identifies this class.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Prompt(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Prompt(software.amazon.jsii.JsiiObjectRef objRef)
     
     
    Prompt(software.constructs.Construct scope, String id, PromptProps props)
    (experimental) **************************************************************************** CONSTRUCTOR ***************************************************************************.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    (experimental) Adds a prompt variant to the prompt.
    (experimental) Creates a prompt version, a static snapshot of your prompt that can be deployed to production.
    createVersion(String description)
    (experimental) Creates a prompt version, a static snapshot of your prompt that can be deployed to production.
    static IPrompt
    fromPromptAttributes(software.constructs.Construct scope, String id, PromptAttributes attrs)
    (experimental) Creates a Prompt reference from an existing prompt's attributes.
    (experimental) The description of the prompt.
    (experimental) The KMS key that the prompt is encrypted with.
    (experimental) The ARN of the prompt.
    (experimental) The ID of the prompt.
    (experimental) The name of the prompt.
    (experimental) The version of the prompt.
    (experimental) The variants of the prompt.

    Methods inherited from class software.amazon.awscdk.services.bedrock.alpha.PromptBase

    grantGet

    Methods inherited from class software.constructs.Construct

    getNode, isConstruct, toString

    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, wait, wait, wait

    Methods inherited from interface software.constructs.IConstruct

    getNode

    Methods inherited from interface software.amazon.awscdk.services.bedrock.alpha.IPrompt

    grantGet

    Methods inherited from interface software.amazon.awscdk.IResource

    applyRemovalPolicy, getEnv, getStack

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • 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