- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
CreatePromptVersionCommand
Creates a static snapshot of your prompt that can be deployed to production. For more information, see Deploy prompts using Prompt management by creating versions in the Amazon Bedrock User Guide.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { BedrockAgentClient, CreatePromptVersionCommand } from "@aws-sdk/client-bedrock-agent"; // ES Modules import
// const { BedrockAgentClient, CreatePromptVersionCommand } = require("@aws-sdk/client-bedrock-agent"); // CommonJS import
const client = new BedrockAgentClient(config);
const input = { // CreatePromptVersionRequest
promptIdentifier: "STRING_VALUE", // required
description: "STRING_VALUE",
clientToken: "STRING_VALUE",
tags: { // TagsMap
"<keys>": "STRING_VALUE",
},
};
const command = new CreatePromptVersionCommand(input);
const response = await client.send(command);
// { // CreatePromptVersionResponse
// name: "STRING_VALUE", // required
// description: "STRING_VALUE",
// customerEncryptionKeyArn: "STRING_VALUE",
// defaultVariant: "STRING_VALUE",
// variants: [ // PromptVariantList
// { // PromptVariant
// name: "STRING_VALUE", // required
// templateType: "TEXT" || "CHAT", // required
// templateConfiguration: { // PromptTemplateConfiguration Union: only one key present
// text: { // TextPromptTemplateConfiguration
// text: "STRING_VALUE", // required
// cachePoint: { // CachePointBlock
// type: "default", // required
// },
// inputVariables: [ // PromptInputVariablesList
// { // PromptInputVariable
// name: "STRING_VALUE",
// },
// ],
// },
// chat: { // ChatPromptTemplateConfiguration
// messages: [ // Messages // required
// { // Message
// role: "user" || "assistant", // required
// content: [ // ContentBlocks // required
// { // ContentBlock Union: only one key present
// text: "STRING_VALUE",
// cachePoint: {
// type: "default", // required
// },
// },
// ],
// },
// ],
// system: [ // SystemContentBlocks
// { // SystemContentBlock Union: only one key present
// text: "STRING_VALUE",
// cachePoint: "<CachePointBlock>",
// },
// ],
// inputVariables: [
// {
// name: "STRING_VALUE",
// },
// ],
// toolConfiguration: { // ToolConfiguration
// tools: [ // Tools // required
// { // Tool Union: only one key present
// toolSpec: { // ToolSpecification
// name: "STRING_VALUE", // required
// description: "STRING_VALUE",
// inputSchema: { // ToolInputSchema Union: only one key present
// json: "DOCUMENT_VALUE",
// },
// },
// cachePoint: "<CachePointBlock>",
// },
// ],
// toolChoice: { // ToolChoice Union: only one key present
// auto: {},
// any: {},
// tool: { // SpecificToolChoice
// name: "STRING_VALUE", // required
// },
// },
// },
// },
// },
// modelId: "STRING_VALUE",
// inferenceConfiguration: { // PromptInferenceConfiguration Union: only one key present
// text: { // PromptModelInferenceConfiguration
// temperature: Number("float"),
// topP: Number("float"),
// maxTokens: Number("int"),
// stopSequences: [ // StopSequences
// "STRING_VALUE",
// ],
// },
// },
// metadata: [ // PromptMetadataList
// { // PromptMetadataEntry
// key: "STRING_VALUE", // required
// value: "STRING_VALUE", // required
// },
// ],
// additionalModelRequestFields: "DOCUMENT_VALUE",
// genAiResource: { // PromptGenAiResource Union: only one key present
// agent: { // PromptAgentResource
// agentIdentifier: "STRING_VALUE", // required
// },
// },
// },
// ],
// id: "STRING_VALUE", // required
// arn: "STRING_VALUE", // required
// version: "STRING_VALUE", // required
// createdAt: new Date("TIMESTAMP"), // required
// updatedAt: new Date("TIMESTAMP"), // required
// };
CreatePromptVersionCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
promptIdentifier Required | string | undefined | The unique identifier of the prompt that you want to create a version of. |
clientToken | string | undefined | 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 . |
description | string | undefined | A description for the version of the prompt. |
tags | Record<string, string> | undefined | Any tags that you want to attach to the version of the prompt. For more information, see Tagging resources in Amazon Bedrock . |
CreatePromptVersionCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
arn Required | string | undefined | The Amazon Resource Name (ARN) of the version of the prompt. |
createdAt Required | Date | undefined | The time at which the prompt was created. |
id Required | string | undefined | The unique identifier of the prompt. |
name Required | string | undefined | The name of the prompt. |
updatedAt Required | Date | undefined | The time at which the prompt was last updated. |
version Required | string | undefined | The version of the prompt that was created. Versions are numbered incrementally, starting from 1. |
customerEncryptionKeyArn | string | undefined | The Amazon Resource Name (ARN) of the KMS key to encrypt the version of the prompt. |
defaultVariant | string | undefined | The name of the default variant for the prompt. This value must match the |
description | string | undefined | A description for the version. |
variants | PromptVariant[] | undefined | A list of objects, each containing details about a variant of the prompt. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDeniedException | client | The request is denied because of missing access permissions. |
ConflictException | client | There was a conflict performing an operation. |
InternalServerException | server | An internal server error occurred. Retry your request. |
ResourceNotFoundException | client | The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again. |
ServiceQuotaExceededException | client | The number of requests exceeds the service quota. Resubmit your request later. |
ThrottlingException | client | The number of requests exceeds the limit. Resubmit your request later. |
ValidationException | client | Input validation failed. Check your request parameters and retry the request. |
BedrockAgentServiceException | Base exception class for all service exceptions from BedrockAgent service. |