Class Prompt
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.bedrock.alpha.PromptBase
software.amazon.awscdk.services.bedrock.alpha.Prompt
- All Implemented Interfaces:
IEnvironmentAware,IResource,IPrompt,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.121.0 (build d7af9b9)",
date="2025-12-18T18:20:21.216Z")
@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 ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.bedrock.alpha.IPrompt
IPrompt.Jsii$Default, IPrompt.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String(experimental) Uniquely identifies this class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPrompt(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedPrompt(software.amazon.jsii.JsiiObjectRef objRef) Prompt(software.constructs.Construct scope, String id, PromptProps props) (experimental) **************************************************************************** CONSTRUCTOR ***************************************************************************. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVariant(IPromptVariant variant) (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 IPromptfromPromptAttributes(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
grantGetMethods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
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.
id-- Identifier of the construct.
attrs-- Attributes of the existing prompt.
- Returns:
- An IPrompt reference to the existing prompt
-
addVariant
(experimental) Adds a prompt variant to the prompt.- Parameters:
variant-- The prompt variant to add.
-
createVersion
(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
(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
(experimental) The ARN of the prompt.Example:
"arn:aws:bedrock:us-east-1:123456789012:prompt/PROMPT12345";
- Specified by:
getPromptArnin interfaceIPrompt- Specified by:
getPromptArnin classPromptBase
-
getPromptId
(experimental) The ID of the prompt.Example:
"PROMPT12345";
- Specified by:
getPromptIdin interfaceIPrompt- Specified by:
getPromptIdin classPromptBase
-
getPromptName
(experimental) The name of the prompt. -
getPromptVersion
(experimental) The version of the prompt.- Specified by:
getPromptVersionin interfaceIPrompt- Specified by:
getPromptVersionin classPromptBase
-
getVariants
(experimental) The variants of the prompt. -
getDescription
(experimental) The description of the prompt. -
getKmsKey
(experimental) The KMS key that the prompt is encrypted with.- Specified by:
getKmsKeyin interfaceIPrompt- Specified by:
getKmsKeyin classPromptBase
-