CreateAgent - Amazon Bedrock

CreateAgent

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 AWS 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 override the default prompt behavior for agent orchestration and to use advanced prompts, include a promptOverrideConfiguration object. For more information, see Advanced prompts.

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

Request Syntax

PUT /agents/ HTTP/1.1 Content-type: application/json { "agentName": "string", "agentResourceRoleArn": "string", "clientToken": "string", "customerEncryptionKeyArn": "string", "description": "string", "foundationModel": "string", "idleSessionTTLInSeconds": number, "instruction": "string", "promptOverrideConfiguration": { "overrideLambda": "string", "promptConfigurations": [ { "basePromptTemplate": "string", "inferenceConfiguration": { "maximumLength": number, "stopSequences": [ "string" ], "temperature": number, "topK": number, "topP": number }, "parserMode": "string", "promptCreationMode": "string", "promptState": "string", "promptType": "string" } ] }, "tags": { "string" : "string" } }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

agentName

A name for the agent that you create.

Type: String

Pattern: ^([0-9a-zA-Z][_-]?){1,100}$

Required: Yes

agentResourceRoleArn

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

Type: String

Length Constraints: Minimum length of 0. Maximum length of 2048.

Pattern: ^arn:aws(-[^:]+)?:iam::([0-9]{12})?:role/(service-role/)?AmazonBedrockExecutionRoleForAgents_.+$

Required: No

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.

Type: String

Length Constraints: Minimum length of 33. Maximum length of 256.

Pattern: ^[a-zA-Z0-9](-*[a-zA-Z0-9])*$

Required: No

customerEncryptionKeyArn

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

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: ^arn:aws(|-cn|-us-gov):kms:[a-zA-Z0-9-]*:[0-9]{12}:key/[a-zA-Z0-9-]{36}$

Required: No

description

A description of the agent.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 200.

Required: No

foundationModel

The foundation model to be used for orchestration by the agent you create.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: ^arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}(([:][a-z0-9-]{1,63}){0,2})?/[a-z0-9]{12})|(:foundation-model/([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63})([:][a-z0-9-]{1,63}){0,2})))|(([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63})([:][a-z0-9-]{1,63}){0,2}))|(([0-9a-zA-Z][_-]?)+)$

Required: No

idleSessionTTLInSeconds

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.

Type: Integer

Valid Range: Minimum value of 60. Maximum value of 3600.

Required: No

instruction

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

Type: String

Length Constraints: Minimum length of 40. Maximum length of 1200.

Required: No

promptOverrideConfiguration

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

Type: PromptOverrideConfiguration object

Required: No

tags

Any tags that you want to attach to the agent.

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Key Pattern: ^[a-zA-Z0-9\s._:/=+@-]*$

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Value Pattern: ^[a-zA-Z0-9\s._:/=+@-]*$

Required: No

Response Syntax

HTTP/1.1 202 Content-type: application/json { "agent": { "agentArn": "string", "agentId": "string", "agentName": "string", "agentResourceRoleArn": "string", "agentStatus": "string", "agentVersion": "string", "clientToken": "string", "createdAt": "string", "customerEncryptionKeyArn": "string", "description": "string", "failureReasons": [ "string" ], "foundationModel": "string", "idleSessionTTLInSeconds": number, "instruction": "string", "preparedAt": "string", "promptOverrideConfiguration": { "overrideLambda": "string", "promptConfigurations": [ { "basePromptTemplate": "string", "inferenceConfiguration": { "maximumLength": number, "stopSequences": [ "string" ], "temperature": number, "topK": number, "topP": number }, "parserMode": "string", "promptCreationMode": "string", "promptState": "string", "promptType": "string" } ] }, "recommendedActions": [ "string" ], "updatedAt": "string" } }

Response Elements

If the action is successful, the service sends back an HTTP 202 response.

The following data is returned in JSON format by the service.

agent

Contains details about the agent created.

Type: Agent object

Errors

For information about the errors that are common to all actions, see Common Errors.

AccessDeniedException

The request is denied because of missing access permissions.

HTTP Status Code: 403

ConflictException

There was a conflict performing an operation.

HTTP Status Code: 409

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500

ServiceQuotaExceededException

The number of requests exceeds the service quota. Resubmit your request later.

HTTP Status Code: 402

ThrottlingException

The number of requests exceeds the limit. Resubmit your request later.

HTTP Status Code: 429

ValidationException

Input validation failed. Check your request parameters and retry the request.

HTTP Status Code: 400

Examples

Example request

This example illustrates one usage of CreateAgent.

PUT /agents/ HTTP/1.1 Content-type: application/json { "agentName": "o1nvve1", "agentResourceRoleArn": "arn:aws:iam::123456789012:role/AmazonBedrockExecutionRoleForAgents_user", "instruction": "You are an IT agent who solves customer's problems", "description": "Description is here", "idleSessionTTLInSeconds": 900, "foundationModel": "anthropic.claude-v2" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: