Skip to content

Examples#

Index > BedrockRuntime > Examples

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

Client#

Implicit type annotations#

Can be used with boto3-stubs[bedrock-runtime] package installed.

Write your BedrockRuntime code as usual, type checking and code completion should work out of the box.

# BedrockRuntimeClient usage example

from boto3.session import Session


session = Session()

client = session.client("bedrock-runtime")  # (1)
result = client.invoke_model()  # (2)
  1. client: BedrockRuntimeClient
  2. result: InvokeModelResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[bedrock-runtime] or a standalone mypy_boto3_bedrock_runtime package, you have to explicitly specify client: BedrockRuntimeClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# BedrockRuntimeClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_bedrock_runtime.client import BedrockRuntimeClient
from mypy_boto3_bedrock_runtime.type_defs import InvokeModelResponseTypeDef
from mypy_boto3_bedrock_runtime.type_defs import InvokeModelRequestRequestTypeDef


session = Session()

client: BedrockRuntimeClient = session.client("bedrock-runtime")

kwargs: InvokeModelRequestRequestTypeDef = {...}
result: InvokeModelResponseTypeDef = client.invoke_model(**kwargs)