createPrompt method
Creates a prompt in your prompt library that you can add to a flow. For more information, see Prompt management in Amazon Bedrock, Create a prompt using Prompt management and Prompt flows in Amazon Bedrock in the Amazon Bedrock User Guide.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter name :
A name for the prompt.
Parameter clientToken :
A unique, case-sensitive identifier to ensure that the API request
completes no more than one time. If this token matches a previous request,
Amazon Bedrock ignores the request, but does not return an error. For more
information, see Ensuring
idempotency.
Parameter customerEncryptionKeyArn :
The Amazon Resource Name (ARN) of the KMS key to encrypt the prompt.
Parameter defaultVariant :
The name of the default variant for the prompt. This value must match the
name field in the relevant PromptVariant
object.
Parameter description :
A description for the prompt.
Parameter tags :
Any tags that you want to attach to the prompt. For more information, see
Tagging
resources in Amazon Bedrock.
Parameter variants :
A list of objects, each containing details about a variant of the prompt.
Implementation
Future<CreatePromptResponse> createPrompt({
required String name,
String? clientToken,
String? customerEncryptionKeyArn,
String? defaultVariant,
String? description,
Map<String, String>? tags,
List<PromptVariant>? variants,
}) async {
final $payload = <String, dynamic>{
'name': name,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (customerEncryptionKeyArn != null)
'customerEncryptionKeyArn': customerEncryptionKeyArn,
if (defaultVariant != null) 'defaultVariant': defaultVariant,
if (description != null) 'description': description,
if (tags != null) 'tags': tags,
if (variants != null) 'variants': variants,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/prompts/',
exceptionFnMap: _exceptionFns,
);
return CreatePromptResponse.fromJson(response);
}