Skip to content

AgentsforBedrockRuntimeClient#

Index > AgentsforBedrockRuntime > AgentsforBedrockRuntimeClient

Auto-generated documentation for AgentsforBedrockRuntime type annotations stubs module mypy-boto3-bedrock-agent-runtime.

AgentsforBedrockRuntimeClient#

Type annotations and code completion for boto3.client("bedrock-agent-runtime"). boto3 documentation

# AgentsforBedrockRuntimeClient usage example

from boto3.session import Session
from mypy_boto3_bedrock_agent_runtime.client import AgentsforBedrockRuntimeClient

def get_bedrock-agent-runtime_client() -> AgentsforBedrockRuntimeClient:
    return Session().client("bedrock-agent-runtime")

Exceptions#

boto3 client exceptions are generated in runtime. This class provides code completion for boto3.client("bedrock-agent-runtime").exceptions structure.

# Exceptions.exceptions usage example

client = boto3.client("bedrock-agent-runtime")

try:
    do_something(client)
except (
    client.exceptions.AccessDeniedException,
    client.exceptions.BadGatewayException,
    client.exceptions.ClientError,
    client.exceptions.ConflictException,
    client.exceptions.DependencyFailedException,
    client.exceptions.InternalServerException,
    client.exceptions.ModelNotReadyException,
    client.exceptions.ResourceNotFoundException,
    client.exceptions.ServiceQuotaExceededException,
    client.exceptions.ThrottlingException,
    client.exceptions.ValidationException,
) as e:
    print(e)
# Exceptions.exceptions type checking example

from mypy_boto3_bedrock_agent_runtime.client import Exceptions

def handle_error(exc: Exceptions.AccessDeniedException) -> None:
    ...

Methods#

can_paginate#

Type annotations and code completion for boto3.client("bedrock-agent-runtime").can_paginate method. boto3 documentation

# can_paginate method definition

def can_paginate(
    self,
    operation_name: str,
) -> bool:
    ...

generate_presigned_url#

Type annotations and code completion for boto3.client("bedrock-agent-runtime").generate_presigned_url method. boto3 documentation

# generate_presigned_url method definition

def generate_presigned_url(
    self,
    ClientMethod: str,
    Params: Mapping[str, Any] = ...,
    ExpiresIn: int = 3600,
    HttpMethod: str = ...,
) -> str:
    ...

delete_agent_memory#

Deletes memory from the specified memory identifier.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").delete_agent_memory method. boto3 documentation

# delete_agent_memory method definition

def delete_agent_memory(
    self,
    *,
    agentAliasId: str,
    agentId: str,
    memoryId: str = ...,
    sessionId: str = ...,
) -> dict[str, Any]:
    ...
# delete_agent_memory method usage example with argument unpacking

kwargs: DeleteAgentMemoryRequestRequestTypeDef = {  # (1)
    "agentAliasId": ...,
    "agentId": ...,
}

parent.delete_agent_memory(**kwargs)
  1. See DeleteAgentMemoryRequestRequestTypeDef

generate_query#

Generates an SQL query from a natural language query.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").generate_query method. boto3 documentation

# generate_query method definition

def generate_query(
    self,
    *,
    queryGenerationInput: QueryGenerationInputTypeDef,  # (1)
    transformationConfiguration: TransformationConfigurationTypeDef,  # (2)
) -> GenerateQueryResponseTypeDef:  # (3)
    ...
  1. See QueryGenerationInputTypeDef
  2. See TransformationConfigurationTypeDef
  3. See GenerateQueryResponseTypeDef
# generate_query method usage example with argument unpacking

kwargs: GenerateQueryRequestRequestTypeDef = {  # (1)
    "queryGenerationInput": ...,
    "transformationConfiguration": ...,
}

parent.generate_query(**kwargs)
  1. See GenerateQueryRequestRequestTypeDef

get_agent_memory#

Gets the sessions stored in the memory of the agent.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").get_agent_memory method. boto3 documentation

# get_agent_memory method definition

def get_agent_memory(
    self,
    *,
    agentAliasId: str,
    agentId: str,
    memoryId: str,
    memoryType: MemoryTypeType,  # (1)
    maxItems: int = ...,
    nextToken: str = ...,
) -> GetAgentMemoryResponseTypeDef:  # (2)
    ...
  1. See MemoryTypeType
  2. See GetAgentMemoryResponseTypeDef
# get_agent_memory method usage example with argument unpacking

kwargs: GetAgentMemoryRequestRequestTypeDef = {  # (1)
    "agentAliasId": ...,
    "agentId": ...,
    "memoryId": ...,
    "memoryType": ...,
}

parent.get_agent_memory(**kwargs)
  1. See GetAgentMemoryRequestRequestTypeDef

invoke_agent#

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

Type annotations and code completion for boto3.client("bedrock-agent-runtime").invoke_agent method. boto3 documentation

# invoke_agent method definition

def invoke_agent(
    self,
    *,
    agentAliasId: str,
    agentId: str,
    sessionId: str,
    bedrockModelConfigurations: BedrockModelConfigurationsTypeDef = ...,  # (1)
    enableTrace: bool = ...,
    endSession: bool = ...,
    inputText: str = ...,
    memoryId: str = ...,
    sessionState: SessionStateTypeDef = ...,  # (2)
    sourceArn: str = ...,
    streamingConfigurations: StreamingConfigurationsTypeDef = ...,  # (3)
) -> InvokeAgentResponseTypeDef:  # (4)
    ...
  1. See BedrockModelConfigurationsTypeDef
  2. See SessionStateTypeDef
  3. See StreamingConfigurationsTypeDef
  4. See InvokeAgentResponseTypeDef
# invoke_agent method usage example with argument unpacking

kwargs: InvokeAgentRequestRequestTypeDef = {  # (1)
    "agentAliasId": ...,
    "agentId": ...,
    "sessionId": ...,
}

parent.invoke_agent(**kwargs)
  1. See InvokeAgentRequestRequestTypeDef

invoke_flow#

Invokes an alias of a flow to run the inputs that you specify and return the output of each node as a stream.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").invoke_flow method. boto3 documentation

# invoke_flow method definition

def invoke_flow(
    self,
    *,
    flowAliasIdentifier: str,
    flowIdentifier: str,
    inputs: Sequence[FlowInputTypeDef],  # (1)
    enableTrace: bool = ...,
    modelPerformanceConfiguration: ModelPerformanceConfigurationTypeDef = ...,  # (2)
) -> InvokeFlowResponseTypeDef:  # (3)
    ...
  1. See FlowInputTypeDef
  2. See ModelPerformanceConfigurationTypeDef
  3. See InvokeFlowResponseTypeDef
# invoke_flow method usage example with argument unpacking

kwargs: InvokeFlowRequestRequestTypeDef = {  # (1)
    "flowAliasIdentifier": ...,
    "flowIdentifier": ...,
    "inputs": ...,
}

parent.invoke_flow(**kwargs)
  1. See InvokeFlowRequestRequestTypeDef

invoke_inline_agent#

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

Type annotations and code completion for boto3.client("bedrock-agent-runtime").invoke_inline_agent method. boto3 documentation

# invoke_inline_agent method definition

def invoke_inline_agent(
    self,
    *,
    foundationModel: str,
    instruction: str,
    sessionId: str,
    actionGroups: Sequence[AgentActionGroupTypeDef] = ...,  # (1)
    bedrockModelConfigurations: InlineBedrockModelConfigurationsTypeDef = ...,  # (2)
    customerEncryptionKeyArn: str = ...,
    enableTrace: bool = ...,
    endSession: bool = ...,
    guardrailConfiguration: GuardrailConfigurationWithArnTypeDef = ...,  # (3)
    idleSessionTTLInSeconds: int = ...,
    inlineSessionState: InlineSessionStateTypeDef = ...,  # (4)
    inputText: str = ...,
    knowledgeBases: Sequence[KnowledgeBaseTypeDef] = ...,  # (5)
    promptOverrideConfiguration: PromptOverrideConfigurationTypeDef = ...,  # (6)
) -> InvokeInlineAgentResponseTypeDef:  # (7)
    ...
  1. See AgentActionGroupTypeDef
  2. See InlineBedrockModelConfigurationsTypeDef
  3. See GuardrailConfigurationWithArnTypeDef
  4. See InlineSessionStateTypeDef
  5. See KnowledgeBaseTypeDef
  6. See PromptOverrideConfigurationTypeDef
  7. See InvokeInlineAgentResponseTypeDef
# invoke_inline_agent method usage example with argument unpacking

kwargs: InvokeInlineAgentRequestRequestTypeDef = {  # (1)
    "foundationModel": ...,
    "instruction": ...,
    "sessionId": ...,
}

parent.invoke_inline_agent(**kwargs)
  1. See InvokeInlineAgentRequestRequestTypeDef

optimize_prompt#

Optimizes a prompt for the task that you specify.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").optimize_prompt method. boto3 documentation

# optimize_prompt method definition

def optimize_prompt(
    self,
    *,
    input: InputPromptTypeDef,  # (1)
    targetModelId: str,
) -> OptimizePromptResponseTypeDef:  # (2)
    ...
  1. See InputPromptTypeDef
  2. See OptimizePromptResponseTypeDef
# optimize_prompt method usage example with argument unpacking

kwargs: OptimizePromptRequestRequestTypeDef = {  # (1)
    "input": ...,
    "targetModelId": ...,
}

parent.optimize_prompt(**kwargs)
  1. See OptimizePromptRequestRequestTypeDef

rerank#

Reranks the relevance of sources based on queries.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").rerank method. boto3 documentation

# rerank method definition

def rerank(
    self,
    *,
    queries: Sequence[RerankQueryTypeDef],  # (1)
    rerankingConfiguration: RerankingConfigurationTypeDef,  # (2)
    sources: Sequence[RerankSourceTypeDef],  # (3)
    nextToken: str = ...,
) -> RerankResponseTypeDef:  # (4)
    ...
  1. See RerankQueryTypeDef
  2. See RerankingConfigurationTypeDef
  3. See RerankSourceTypeDef
  4. See RerankResponseTypeDef
# rerank method usage example with argument unpacking

kwargs: RerankRequestRequestTypeDef = {  # (1)
    "queries": ...,
    "rerankingConfiguration": ...,
    "sources": ...,
}

parent.rerank(**kwargs)
  1. See RerankRequestRequestTypeDef

retrieve#

Queries a knowledge base and retrieves information from it.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").retrieve method. boto3 documentation

# retrieve method definition

def retrieve(
    self,
    *,
    knowledgeBaseId: str,
    retrievalQuery: KnowledgeBaseQueryTypeDef,  # (1)
    guardrailConfiguration: GuardrailConfigurationTypeDef = ...,  # (2)
    nextToken: str = ...,
    retrievalConfiguration: KnowledgeBaseRetrievalConfigurationTypeDef = ...,  # (3)
) -> RetrieveResponseTypeDef:  # (4)
    ...
  1. See KnowledgeBaseQueryTypeDef
  2. See GuardrailConfigurationTypeDef
  3. See KnowledgeBaseRetrievalConfigurationTypeDef
  4. See RetrieveResponseTypeDef
# retrieve method usage example with argument unpacking

kwargs: RetrieveRequestRequestTypeDef = {  # (1)
    "knowledgeBaseId": ...,
    "retrievalQuery": ...,
}

parent.retrieve(**kwargs)
  1. See RetrieveRequestRequestTypeDef

retrieve_and_generate#

Queries a knowledge base and generates responses based on the retrieved results and using the specified foundation model or inference profile.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").retrieve_and_generate method. boto3 documentation

# retrieve_and_generate method definition

def retrieve_and_generate(
    self,
    *,
    input: RetrieveAndGenerateInputTypeDef,  # (1)
    retrieveAndGenerateConfiguration: RetrieveAndGenerateConfigurationTypeDef = ...,  # (2)
    sessionConfiguration: RetrieveAndGenerateSessionConfigurationTypeDef = ...,  # (3)
    sessionId: str = ...,
) -> RetrieveAndGenerateResponseTypeDef:  # (4)
    ...
  1. See RetrieveAndGenerateInputTypeDef
  2. See RetrieveAndGenerateConfigurationTypeDef
  3. See RetrieveAndGenerateSessionConfigurationTypeDef
  4. See RetrieveAndGenerateResponseTypeDef
# retrieve_and_generate method usage example with argument unpacking

kwargs: RetrieveAndGenerateRequestRequestTypeDef = {  # (1)
    "input": ...,
}

parent.retrieve_and_generate(**kwargs)
  1. See RetrieveAndGenerateRequestRequestTypeDef

retrieve_and_generate_stream#

Queries a knowledge base and generates responses based on the retrieved results, with output in streaming format.

Type annotations and code completion for boto3.client("bedrock-agent-runtime").retrieve_and_generate_stream method. boto3 documentation

# retrieve_and_generate_stream method definition

def retrieve_and_generate_stream(
    self,
    *,
    input: RetrieveAndGenerateInputTypeDef,  # (1)
    retrieveAndGenerateConfiguration: RetrieveAndGenerateConfigurationTypeDef = ...,  # (2)
    sessionConfiguration: RetrieveAndGenerateSessionConfigurationTypeDef = ...,  # (3)
    sessionId: str = ...,
) -> RetrieveAndGenerateStreamResponseTypeDef:  # (4)
    ...
  1. See RetrieveAndGenerateInputTypeDef
  2. See RetrieveAndGenerateConfigurationTypeDef
  3. See RetrieveAndGenerateSessionConfigurationTypeDef
  4. See RetrieveAndGenerateStreamResponseTypeDef
# retrieve_and_generate_stream method usage example with argument unpacking

kwargs: RetrieveAndGenerateStreamRequestRequestTypeDef = {  # (1)
    "input": ...,
}

parent.retrieve_and_generate_stream(**kwargs)
  1. See RetrieveAndGenerateStreamRequestRequestTypeDef

get_paginator#

Type annotations and code completion for boto3.client("bedrock-agent-runtime").get_paginator method with overloads.