Skip to content

BedrockRuntimeClient#

Index > BedrockRuntime > BedrockRuntimeClient

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

BedrockRuntimeClient#

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

# BedrockRuntimeClient usage example

from boto3.session import Session
from mypy_boto3_bedrock_runtime.client import BedrockRuntimeClient

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

Exceptions#

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

# Exceptions.exceptions usage example

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

try:
    do_something(client)
except (
    client.exceptions.AccessDeniedException,
    client.exceptions.ClientError,
    client.exceptions.InternalServerException,
    client.exceptions.ModelErrorException,
    client.exceptions.ModelNotReadyException,
    client.exceptions.ModelStreamErrorException,
    client.exceptions.ModelTimeoutException,
    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_runtime.client import Exceptions

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

Methods#

can_paginate#

Check if an operation can be paginated.

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

# can_paginate method definition

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

close#

Closes underlying endpoint connections.

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

# close method definition

def close(
    self,
) -> None:
    ...

converse#

Sends messages to the specified Amazon Bedrock model.

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

# converse method definition

def converse(
    self,
    *,
    modelId: str,
    messages: Sequence[Union[MessageTypeDef, MessageOutputTypeDef]],  # (1)
    system: Sequence[SystemContentBlockTypeDef] = ...,  # (2)
    inferenceConfig: InferenceConfigurationTypeDef = ...,  # (3)
    toolConfig: ToolConfigurationTypeDef = ...,  # (4)
    additionalModelRequestFields: Mapping[str, Any] = ...,
    additionalModelResponseFieldPaths: Sequence[str] = ...,
) -> ConverseResponseTypeDef:  # (5)
    ...
  1. See MessageTypeDef MessageOutputTypeDef
  2. See SystemContentBlockTypeDef
  3. See InferenceConfigurationTypeDef
  4. See ToolConfigurationTypeDef
  5. See ConverseResponseTypeDef
# converse method usage example with argument unpacking

kwargs: ConverseRequestRequestTypeDef = {  # (1)
    "modelId": ...,
    "messages": ...,
}

parent.converse(**kwargs)
  1. See ConverseRequestRequestTypeDef

converse_stream#

Sends messages to the specified Amazon Bedrock model and returns the response in a stream.

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

# converse_stream method definition

def converse_stream(
    self,
    *,
    modelId: str,
    messages: Sequence[Union[MessageTypeDef, MessageOutputTypeDef]],  # (1)
    system: Sequence[SystemContentBlockTypeDef] = ...,  # (2)
    inferenceConfig: InferenceConfigurationTypeDef = ...,  # (3)
    toolConfig: ToolConfigurationTypeDef = ...,  # (4)
    additionalModelRequestFields: Mapping[str, Any] = ...,
    additionalModelResponseFieldPaths: Sequence[str] = ...,
) -> ConverseStreamResponseTypeDef:  # (5)
    ...
  1. See MessageTypeDef MessageOutputTypeDef
  2. See SystemContentBlockTypeDef
  3. See InferenceConfigurationTypeDef
  4. See ToolConfigurationTypeDef
  5. See ConverseStreamResponseTypeDef
# converse_stream method usage example with argument unpacking

kwargs: ConverseStreamRequestRequestTypeDef = {  # (1)
    "modelId": ...,
    "messages": ...,
}

parent.converse_stream(**kwargs)
  1. See ConverseStreamRequestRequestTypeDef

generate_presigned_url#

Generate a presigned url given a client, its method, and arguments.

Type annotations and code completion for boto3.client("bedrock-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:
    ...

invoke_model#

Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.

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

# invoke_model method definition

def invoke_model(
    self,
    *,
    body: Union[str, bytes, IO[Any], StreamingBody],
    modelId: str,
    contentType: str = ...,
    accept: str = ...,
    trace: TraceType = ...,  # (1)
    guardrailIdentifier: str = ...,
    guardrailVersion: str = ...,
) -> InvokeModelResponseTypeDef:  # (2)
    ...
  1. See TraceType
  2. See InvokeModelResponseTypeDef
# invoke_model method usage example with argument unpacking

kwargs: InvokeModelRequestRequestTypeDef = {  # (1)
    "body": ...,
    "modelId": ...,
}

parent.invoke_model(**kwargs)
  1. See InvokeModelRequestRequestTypeDef

invoke_model_with_response_stream#

Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.

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

# invoke_model_with_response_stream method definition

def invoke_model_with_response_stream(
    self,
    *,
    body: Union[str, bytes, IO[Any], StreamingBody],
    modelId: str,
    contentType: str = ...,
    accept: str = ...,
    trace: TraceType = ...,  # (1)
    guardrailIdentifier: str = ...,
    guardrailVersion: str = ...,
) -> InvokeModelWithResponseStreamResponseTypeDef:  # (2)
    ...
  1. See TraceType
  2. See InvokeModelWithResponseStreamResponseTypeDef
# invoke_model_with_response_stream method usage example with argument unpacking

kwargs: InvokeModelWithResponseStreamRequestRequestTypeDef = {  # (1)
    "body": ...,
    "modelId": ...,
}

parent.invoke_model_with_response_stream(**kwargs)
  1. See InvokeModelWithResponseStreamRequestRequestTypeDef