InvokeInlineAgent - Amazon Bedrock

InvokeInlineAgent

Invokes an inline Amazon Bedrock agent using the configurations you provide with the request.

  • Specify the following fields for security purposes.

    • (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 InvokeInlineAgent 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.

  • 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.

Note

The AWS CLI doesn't support streaming operations in Amazon Bedrock, including InvokeInlineAgent.

Request Syntax

POST /agents/sessionId HTTP/1.1 Content-type: application/json { "actionGroups": [ { "actionGroupExecutor": { ... }, "actionGroupName": "string", "apiSchema": { ... }, "description": "string", "functionSchema": { ... }, "parentActionGroupSignature": "string" } ], "bedrockModelConfigurations": { "performanceConfig": { "latency": "string" } }, "customerEncryptionKeyArn": "string", "enableTrace": boolean, "endSession": boolean, "foundationModel": "string", "guardrailConfiguration": { "guardrailIdentifier": "string", "guardrailVersion": "string" }, "idleSessionTTLInSeconds": number, "inlineSessionState": { "files": [ { "name": "string", "source": { "byteContent": { "data": blob, "mediaType": "string" }, "s3Location": { "uri": "string" }, "sourceType": "string" }, "useCase": "string" } ], "invocationId": "string", "promptSessionAttributes": { "string" : "string" }, "returnControlInvocationResults": [ { ... } ], "sessionAttributes": { "string" : "string" } }, "inputText": "string", "instruction": "string", "knowledgeBases": [ { "description": "string", "knowledgeBaseId": "string", "retrievalConfiguration": { "vectorSearchConfiguration": { "filter": { ... }, "implicitFilterConfiguration": { "metadataAttributes": [ { "description": "string", "key": "string", "type": "string" } ], "modelArn": "string" }, "numberOfResults": number, "overrideSearchType": "string", "rerankingConfiguration": { "bedrockRerankingConfiguration": { "metadataConfiguration": { "selectionMode": "string", "selectiveModeConfiguration": { ... } }, "modelConfiguration": { "additionalModelRequestFields": { "string" : JSON value }, "modelArn": "string" }, "numberOfRerankedResults": number }, "type": "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" } ] } }

URI Request Parameters

The request uses the following URI parameters.

sessionId

The unique identifier of the session. Use the same value across requests to continue the same conversation.

Length Constraints: Minimum length of 2. Maximum length of 100.

Pattern: ^[0-9a-zA-Z._:-]+$

Required: Yes

Request Body

The request accepts the following data in JSON format.

actionGroups

A list of action groups with each action group defining the action the inline agent needs to carry out.

Type: Array of AgentActionGroup objects

Required: No

bedrockModelConfigurations

Model settings for the request.

Type: InlineBedrockModelConfigurations object

Required: No

customerEncryptionKeyArn

The Amazon Resource Name (ARN) of the AWS KMS key to use to encrypt your inline 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

enableTrace

Specifies whether to turn on the trace or not to track the agent's reasoning process. For more information, see Using trace.

Type: Boolean

Required: No

endSession

Specifies whether to end the session with the inline agent or not.

Type: Boolean

Required: No

foundationModel

The model identifier (ID) of the model to use for orchestration by the inline agent. For example, meta.llama3-1-70b-instruct-v1:0.

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][_-]?)+))$|(^arn:aws(|-us-gov|-cn|-iso|-iso-b):bedrock:(|[0-9a-z-]{1,20}):(|[0-9]{12}):inference-profile/[a-zA-Z0-9-:.]+)$

Required: Yes

guardrailConfiguration

The guardrails to assign to the inline agent.

Type: GuardrailConfigurationWithArn object

Required: No

idleSessionTTLInSeconds

The number of seconds for which the inline agent should maintain session information. After this time expires, the subsequent InvokeInlineAgent request begins a new session.

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

Type: Integer

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

Required: No

inlineSessionState

Parameters that specify the various attributes of a sessions. You can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group. For more information, see Control session context.

Note

If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.

Type: InlineSessionState object

Required: No

inputText

The prompt text to send to the agent.

Note

If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.

Type: String

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

Required: No

instruction

The instructions that tell the inline agent what it should do and how it should interact with users.

Type: String

Length Constraints: Minimum length of 40.

Required: Yes

knowledgeBases

Contains information of the knowledge bases to associate with.

Type: Array of KnowledgeBase objects

Required: No

promptOverrideConfiguration

Configurations for advanced prompts used to override the default prompts to enhance the accuracy of the inline agent.

Type: PromptOverrideConfiguration object

Required: No

Response Syntax

HTTP/1.1 200 x-amzn-bedrock-agent-content-type: contentType x-amz-bedrock-agent-session-id: sessionId Content-type: application/json { "accessDeniedException": { }, "badGatewayException": { }, "chunk": { "attribution": { "citations": [ { "generatedResponsePart": { "textResponsePart": { "span": { "end": number, "start": number }, "text": "string" } }, "retrievedReferences": [ { "content": { "byteContent": "string", "row": [ { "columnName": "string", "columnValue": "string", "type": "string" } ], "text": "string", "type": "string" }, "location": { "confluenceLocation": { "url": "string" }, "customDocumentLocation": { "id": "string" }, "kendraDocumentLocation": { "uri": "string" }, "s3Location": { "uri": "string" }, "salesforceLocation": { "url": "string" }, "sharePointLocation": { "url": "string" }, "sqlLocation": { "query": "string" }, "type": "string", "webLocation": { "url": "string" } }, "metadata": { "string" : JSON value } } ] } ] }, "bytes": blob }, "conflictException": { }, "dependencyFailedException": { }, "files": { "files": [ { "bytes": blob, "name": "string", "type": "string" } ] }, "internalServerException": { }, "resourceNotFoundException": { }, "returnControl": { "invocationId": "string", "invocationInputs": [ { ... } ] }, "serviceQuotaExceededException": { }, "throttlingException": { }, "trace": { "sessionId": "string", "trace": { ... } }, "validationException": { } }

Response Elements

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

The response returns the following HTTP headers.

contentType

The MIME type of the input data in the request. The default value is application/json.

sessionId

The unique identifier of the session with the agent.

Length Constraints: Minimum length of 2. Maximum length of 100.

Pattern: ^[0-9a-zA-Z._:-]+$

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

accessDeniedException

The request is denied because of missing access permissions. Check your permissions and retry your request.

Type: Exception

HTTP Status Code: 403
badGatewayException

There was an issue with a dependency due to a server issue. Retry your request.

Type: Exception

HTTP Status Code: 502
chunk

Contains a part of an agent response and citations for it.

Type: InlineAgentPayloadPart object

conflictException

There was a conflict performing an operation. Resolve the conflict and retry your request.

Type: Exception

HTTP Status Code: 409
dependencyFailedException

There was an issue with a dependency. Check the resource configurations and retry the request.

Type: Exception

HTTP Status Code: 424
files

Contains intermediate response for code interpreter if any files have been generated.

Type: InlineAgentFilePart object

internalServerException

An internal server error occurred. Retry your request.

Type: Exception

HTTP Status Code: 500
resourceNotFoundException

The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.

Type: Exception

HTTP Status Code: 404
returnControl

Contains the parameters and information that the agent elicited from the customer to carry out an action. This information is returned to the system and can be used in your own setup for fulfilling the action.

Type: InlineAgentReturnControlPayload object

serviceQuotaExceededException

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

Type: Exception

HTTP Status Code: 400
throttlingException

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

Type: Exception

HTTP Status Code: 429
trace

Contains information about the agent and session, alongside the agent's reasoning process and results from calling actions and querying knowledge bases and metadata about the trace. You can use the trace to understand how the agent arrived at the response it provided the customer. For more information, see Trace events.

Type: InlineAgentTracePart object

validationException

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

Type: Exception

HTTP Status Code: 400

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. Check your permissions and retry your request.

HTTP Status Code: 403

BadGatewayException

There was an issue with a dependency due to a server issue. Retry your request.

HTTP Status Code: 502

ConflictException

There was a conflict performing an operation. Resolve the conflict and retry your request.

HTTP Status Code: 409

DependencyFailedException

There was an issue with a dependency. Check the resource configurations and retry the request.

HTTP Status Code: 424

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500

ResourceNotFoundException

The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.

HTTP Status Code: 404

ServiceQuotaExceededException

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

HTTP Status Code: 400

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

See Also

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