CreateAgentCommand

Creates an agent that orchestrates interactions between foundation models, data sources, software applications, user conversations, and APIs to carry out tasks to help customers.

  • Specify the following fields for security purposes.

    • agentResourceRoleArn – The Amazon Resource Name (ARN) of the role with permissions to invoke API operations on an agent.

    • (Optional) customerEncryptionKeyArn – The Amazon Resource Name (ARN) of a KMS key to encrypt the creation of the agent.

    • (Optional) idleSessionTTLinSeconds – Specify the number of seconds for which the agent should maintain session information. After this time expires, the subsequent InvokeAgent request begins a new session.

  • To enable your agent to retain conversational context across multiple sessions, include a memoryConfiguration object. For more information, see Configure memory .

  • To override the default prompt behavior for agent orchestration and to use advanced prompts, include a promptOverrideConfiguration object. For more information, see Advanced prompts .

  • If your agent fails to be created, the response returns a list of failureReasons alongside a list of recommendedActions for you to troubleshoot.

  • The agent instructions will not be honored if your agent has only one knowledge base, uses default prompts, has no action group, and user input is disabled.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { BedrockAgentClient, CreateAgentCommand } from "@aws-sdk/client-bedrock-agent"; // ES Modules import
// const { BedrockAgentClient, CreateAgentCommand } = require("@aws-sdk/client-bedrock-agent"); // CommonJS import
const client = new BedrockAgentClient(config);
const input = { // CreateAgentRequest
  agentName: "STRING_VALUE", // required
  clientToken: "STRING_VALUE",
  instruction: "STRING_VALUE",
  foundationModel: "STRING_VALUE",
  description: "STRING_VALUE",
  orchestrationType: "DEFAULT" || "CUSTOM_ORCHESTRATION",
  customOrchestration: { // CustomOrchestration
    executor: { // OrchestrationExecutor Union: only one key present
      lambda: "STRING_VALUE",
    },
  },
  idleSessionTTLInSeconds: Number("int"),
  agentResourceRoleArn: "STRING_VALUE",
  customerEncryptionKeyArn: "STRING_VALUE",
  tags: { // TagsMap
    "<keys>": "STRING_VALUE",
  },
  promptOverrideConfiguration: { // PromptOverrideConfiguration
    promptConfigurations: [ // PromptConfigurations // required
      { // PromptConfiguration
        promptType: "PRE_PROCESSING" || "ORCHESTRATION" || "POST_PROCESSING" || "KNOWLEDGE_BASE_RESPONSE_GENERATION" || "MEMORY_SUMMARIZATION",
        promptCreationMode: "DEFAULT" || "OVERRIDDEN",
        promptState: "ENABLED" || "DISABLED",
        basePromptTemplate: "STRING_VALUE",
        inferenceConfiguration: { // InferenceConfiguration
          temperature: Number("float"),
          topP: Number("float"),
          topK: Number("int"),
          maximumLength: Number("int"),
          stopSequences: [ // StopSequences
            "STRING_VALUE",
          ],
        },
        parserMode: "DEFAULT" || "OVERRIDDEN",
        foundationModel: "STRING_VALUE",
        additionalModelRequestFields: "DOCUMENT_VALUE",
      },
    ],
    overrideLambda: "STRING_VALUE",
  },
  guardrailConfiguration: { // GuardrailConfiguration
    guardrailIdentifier: "STRING_VALUE",
    guardrailVersion: "STRING_VALUE",
  },
  memoryConfiguration: { // MemoryConfiguration
    enabledMemoryTypes: [ // EnabledMemoryTypes // required
      "SESSION_SUMMARY",
    ],
    storageDays: Number("int"),
    sessionSummaryConfiguration: { // SessionSummaryConfiguration
      maxRecentSessions: Number("int"),
    },
  },
  agentCollaboration: "SUPERVISOR" || "SUPERVISOR_ROUTER" || "DISABLED",
};
const command = new CreateAgentCommand(input);
const response = await client.send(command);
// { // CreateAgentResponse
//   agent: { // Agent
//     agentId: "STRING_VALUE", // required
//     agentName: "STRING_VALUE", // required
//     agentArn: "STRING_VALUE", // required
//     agentVersion: "STRING_VALUE", // required
//     clientToken: "STRING_VALUE",
//     instruction: "STRING_VALUE",
//     agentStatus: "CREATING" || "PREPARING" || "PREPARED" || "NOT_PREPARED" || "DELETING" || "FAILED" || "VERSIONING" || "UPDATING", // required
//     foundationModel: "STRING_VALUE",
//     description: "STRING_VALUE",
//     orchestrationType: "DEFAULT" || "CUSTOM_ORCHESTRATION",
//     customOrchestration: { // CustomOrchestration
//       executor: { // OrchestrationExecutor Union: only one key present
//         lambda: "STRING_VALUE",
//       },
//     },
//     idleSessionTTLInSeconds: Number("int"), // required
//     agentResourceRoleArn: "STRING_VALUE", // required
//     customerEncryptionKeyArn: "STRING_VALUE",
//     createdAt: new Date("TIMESTAMP"), // required
//     updatedAt: new Date("TIMESTAMP"), // required
//     preparedAt: new Date("TIMESTAMP"),
//     failureReasons: [ // FailureReasons
//       "STRING_VALUE",
//     ],
//     recommendedActions: [ // RecommendedActions
//       "STRING_VALUE",
//     ],
//     promptOverrideConfiguration: { // PromptOverrideConfiguration
//       promptConfigurations: [ // PromptConfigurations // required
//         { // PromptConfiguration
//           promptType: "PRE_PROCESSING" || "ORCHESTRATION" || "POST_PROCESSING" || "KNOWLEDGE_BASE_RESPONSE_GENERATION" || "MEMORY_SUMMARIZATION",
//           promptCreationMode: "DEFAULT" || "OVERRIDDEN",
//           promptState: "ENABLED" || "DISABLED",
//           basePromptTemplate: "STRING_VALUE",
//           inferenceConfiguration: { // InferenceConfiguration
//             temperature: Number("float"),
//             topP: Number("float"),
//             topK: Number("int"),
//             maximumLength: Number("int"),
//             stopSequences: [ // StopSequences
//               "STRING_VALUE",
//             ],
//           },
//           parserMode: "DEFAULT" || "OVERRIDDEN",
//           foundationModel: "STRING_VALUE",
//           additionalModelRequestFields: "DOCUMENT_VALUE",
//         },
//       ],
//       overrideLambda: "STRING_VALUE",
//     },
//     guardrailConfiguration: { // GuardrailConfiguration
//       guardrailIdentifier: "STRING_VALUE",
//       guardrailVersion: "STRING_VALUE",
//     },
//     memoryConfiguration: { // MemoryConfiguration
//       enabledMemoryTypes: [ // EnabledMemoryTypes // required
//         "SESSION_SUMMARY",
//       ],
//       storageDays: Number("int"),
//       sessionSummaryConfiguration: { // SessionSummaryConfiguration
//         maxRecentSessions: Number("int"),
//       },
//     },
//     agentCollaboration: "SUPERVISOR" || "SUPERVISOR_ROUTER" || "DISABLED",
//   },
// };

CreateAgentCommand Input

See CreateAgentCommandInput for more details

Parameter
Type
Description
agentName
Required
string | undefined

A name for the agent that you create.

agentCollaboration
AgentCollaboration | undefined

The agent's collaboration role.

agentResourceRoleArn
string | undefined

The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the agent.

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 .

customOrchestration
CustomOrchestration | undefined

Contains details of the custom orchestration configured for the agent.

customerEncryptionKeyArn
string | undefined

The Amazon Resource Name (ARN) of the KMS key with which to encrypt the agent.

description
string | undefined

A description of the agent.

foundationModel
string | undefined

The identifier for the model that you want to be used for orchestration by the agent you create.

The modelId to provide depends on the type of model or throughput that you use:

guardrailConfiguration
GuardrailConfiguration | undefined

The unique Guardrail configuration assigned to the agent when it is created.

idleSessionTTLInSeconds
number | undefined

The number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent.

A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout.

instruction
string | undefined

Instructions that tell the agent what it should do and how it should interact with users.

memoryConfiguration
MemoryConfiguration | undefined

Contains the details of the memory configured for the agent.

orchestrationType
OrchestrationType | undefined

Specifies the type of orchestration strategy for the agent. This is set to DEFAULT orchestration type, by default.

promptOverrideConfiguration
PromptOverrideConfiguration | undefined

Contains configurations to override prompts in different parts of an agent sequence. For more information, see Advanced prompts .

tags
Record<string, string> | undefined

Any tags that you want to attach to the agent.

CreateAgentCommand Output

See CreateAgentCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
agent
Required
Agent | undefined

Contains details about the agent created.

Throws

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.

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.