BedrockAgentCoreDataPlaneFrontingLayer / Client / invoke_agent_runtime

invoke_agent_runtime

BedrockAgentCoreDataPlaneFrontingLayer.Client.invoke_agent_runtime(**kwargs)

Sends a request to an agent runtime in Amazon Bedrock and receives responses in real-time. The agent processes the request using the configured foundation model and any associated knowledge bases or action groups.

To invoke an agent runtime, you must specify the agent runtime ARN and provide a payload containing your request. You can optionally specify a qualifier to target a specific version or alias of the agent.

This operation supports streaming responses, allowing you to receive partial responses as they become available. We recommend using pagination to ensure that the operation returns quickly and successfully when processing large responses.

See also: AWS API Documentation

Request Syntax

response = client.invoke_agent_runtime(
    contentType='string',
    accept='string',
    mcpSessionId='string',
    runtimeSessionId='string',
    mcpProtocolVersion='string',
    runtimeUserId='string',
    traceId='string',
    traceParent='string',
    traceState='string',
    baggage='string',
    agentRuntimeArn='string',
    qualifier='string',
    payload=b'bytes'|file
)
Parameters:
  • contentType (string) – The MIME type of the input data in the payload. This tells the agent runtime how to interpret the payload data. Common values include application/json for JSON data.

  • accept (string) – The desired MIME type for the response from the agent runtime. This tells the agent runtime what format to use for the response data. Common values include application/json for JSON data.

  • mcpSessionId (string) – The identifier of the MCP session.

  • runtimeSessionId (string) –

    The identifier of the runtime session.

    This field is autopopulated if not provided.

  • mcpProtocolVersion (string) – The version of the MCP protocol being used.

  • runtimeUserId (string) – The identifier of the runtime user.

  • traceId (string) – The trace identifier for request tracking.

  • traceParent (string) – The parent trace information for distributed tracing.

  • traceState (string) – The trace state information for distributed tracing.

  • baggage (string) – Additional context information for distributed tracing.

  • agentRuntimeArn (string) –

    [REQUIRED]

    The Amazon Web Services Resource Name (ARN) of the agent runtime to invoke. The ARN uniquely identifies the agent runtime resource in Amazon Bedrock.

  • qualifier (string) – The qualifier to use for the agent runtime. This can be a version number or an alias name that points to a specific version. If not specified, Amazon Bedrock uses the default version of the agent runtime.

  • payload (bytes or seekable file-like object) –

    [REQUIRED]

    The input data to send to the agent runtime. The format of this data depends on the specific agent configuration and must match the specified content type. For most agents, this is a JSON object containing the user’s request.

Return type:

dict

Returns:

Response Syntax

{
    'runtimeSessionId': 'string',
    'mcpSessionId': 'string',
    'mcpProtocolVersion': 'string',
    'traceId': 'string',
    'traceParent': 'string',
    'traceState': 'string',
    'baggage': 'string',
    'contentType': 'string',
    'response': StreamingBody(),
    'statusCode': 123
}

Response Structure

  • (dict) –

    • runtimeSessionId (string) –

      The identifier of the runtime session.

    • mcpSessionId (string) –

      The identifier of the MCP session.

    • mcpProtocolVersion (string) –

      The version of the MCP protocol being used.

    • traceId (string) –

      The trace identifier for request tracking.

    • traceParent (string) –

      The parent trace information for distributed tracing.

    • traceState (string) –

      The trace state information for distributed tracing.

    • baggage (string) –

      Additional context information for distributed tracing.

    • contentType (string) –

      The MIME type of the response data. This indicates how to interpret the response data. Common values include application/json for JSON data.

    • response (StreamingBody) –

      The response data from the agent runtime. The format of this data depends on the specific agent configuration and the requested accept type. For most agents, this is a JSON object containing the agent’s response to the user’s request.

    • statusCode (integer) –

      The HTTP status code of the response. A status code of 200 indicates a successful operation. Other status codes indicate various error conditions.

Exceptions