Skip to content

Examples#

Index > Bedrock > Examples

Auto-generated documentation for Bedrock type annotations stubs module types-aiobotocore-bedrock.

Client#

Implicit type annotations#

Can be used with types-aioboto3[bedrock] package installed.

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

# BedrockClient usage example

from aioboto3.session import Session


session = Session()

async with session.client("bedrock") as client:  # (1)
    result = await client.create_model_customization_job()  # (2)
  1. client: BedrockClient
  2. result: CreateModelCustomizationJobResponseTypeDef
# ListCustomModelsPaginator usage example

from aioboto3.session import Session


session = Session()

async with session.client("bedrock") as client:  # (1)
    paginator = client.get_paginator("list_custom_models")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: BedrockClient
  2. paginator: ListCustomModelsPaginator
  3. item: ListCustomModelsResponseTypeDef

Explicit type annotations#

With types-aioboto3-lite[bedrock] or a standalone types_aiobotocore_bedrock package, you have to explicitly specify client: BedrockClient 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.

# BedrockClient usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_bedrock.client import BedrockClient
from types_aiobotocore_bedrock.type_defs import CreateModelCustomizationJobResponseTypeDef
from types_aiobotocore_bedrock.type_defs import CreateModelCustomizationJobRequestRequestTypeDef


session = Session()

client: BedrockClient
async with session.client("bedrock") as client:  # (1)
    kwargs: CreateModelCustomizationJobRequestRequestTypeDef = {...}  # (2)
    result: CreateModelCustomizationJobResponseTypeDef = await client.create_model_customization_job(**kwargs)  # (3)
  1. client: BedrockClient
  2. kwargs: CreateModelCustomizationJobRequestRequestTypeDef
  3. result: CreateModelCustomizationJobResponseTypeDef
# ListCustomModelsPaginator usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_bedrock.client import BedrockClient
from types_aiobotocore_bedrock.paginator import ListCustomModelsPaginator
from types_aiobotocore_bedrock.type_defs import ListCustomModelsResponseTypeDef


session = Session()

client: BedrockClient
async with session.client("bedrock") as client:  # (1)
    paginator: ListCustomModelsPaginator = client.get_paginator("list_custom_models")  # (2)
    async for item in paginator.paginate(...):
        item: ListCustomModelsResponseTypeDef
        print(item)  # (3)
  1. client: BedrockClient
  2. paginator: ListCustomModelsPaginator
  3. item: ListCustomModelsResponseTypeDef