Registry / type-stubs / types-boto3-bedrock-runtime

types-boto3-bedrock-runtime

JSON →
library1.43.30pypypiunverified

This package provides comprehensive type annotations (stubs) for the `boto3` Bedrock Runtime client, enabling static type checking with tools like `mypy`. It ensures that your interactions with the AWS Bedrock Runtime service are type-safe, catching potential errors at development time. The current version is 1.42.82, and new releases are frequent, typically aligning with `boto3` and `botocore` updates.

pip install types-boto3-bedrock-runtime boto3 mypy
INSTALL
IMPORT
SIG · TYPES-BOTO3-BEDROC
T
types-boto3-bedrock-runtime
type-stubspythonv1.43.30
Install
5.6s avg
Import
12ms
Disk
113MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.43.30 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.010s · 115MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.6s · import 0.007s · 114MB
113MB installed
● package 113MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BedrockRuntimeClient
from typing import TYPE_CHECKING if TYPE_CHECKING: from types_boto3_bedrock_runtime.client import BedrockRuntimeClient
from types_boto3_bedrock_runtime import BedrockRuntimeClient
Type stub packages should only be imported for type checking purposes to avoid runtime overhead or errors. Use `if TYPE_CHECKING:`.
InvokeModelRequestRequestTypeDef
from typing import TYPE_CHECKING if TYPE_CHECKING: from types_boto3_bedrock_runtime.type_defs import InvokeModelRequestRequestTypeDef
Specific type definitions for requests/responses are found in `type_defs` and should also be conditionally imported.

This quickstart demonstrates how to initialize a `boto3` Bedrock Runtime client with type annotations. It shows the conditional import of `BedrockRuntimeClient` and `InvokeModelRequestRequestTypeDef` for static analysis and then uses the client to invoke a model. Remember to set your AWS credentials and region via environment variables or other boto3 configuration methods for actual execution.

import boto3 import os from typing import TYPE_CHECKING # Conditional import for type checking if TYPE_CHECKING: from types_boto3_bedrock_runtime.client import BedrockRuntimeClient from types_boto3_bedrock_runtime.type_defs import InvokeModelRequestRequestTypeDef def invoke_bedrock_model(model_id: str, prompt: str): # Type annotate the client client: BedrockRuntimeClient = boto3.client( 'bedrock-runtime', aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'), aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'), region_name=os.environ.get('AWS_REGION', 'us-east-1') ) body_content = {"prompt": prompt, "max_tokens_to_sample": 200, "temperature": 0.7} # Example of type-hinted request body (mypy will check its structure) request_body: InvokeModelRequestRequestTypeDef = { 'body': str(body_content).encode('utf-8'), # In real use, convert dict to JSON string 'contentType': 'application/json', 'accept': 'application/json', 'modelId': model_id } try: response = client.invoke_model(**request_body) print("Successfully invoked model:") # Process response body (example) response_body = response['body'].read().decode('utf-8') print(response_body) except client.exceptions.AccessDeniedException as e: print(f"Access Denied: {e}") print("Please ensure your AWS credentials and permissions are correctly configured.") except Exception as e: print(f"An error occurred: {e}") # Example usage: if __name__ == "__main__": # Replace with an actual model ID available in your region # e.g., 'anthropic.claude-v2' or 'amazon.titan-text-express-v1' model = "DUMMY_MODEL_ID" user_prompt = "Hello, how are you?" invoke_bedrock_model(model, user_prompt)
Debug
Known issues
breakingStarting with version 8.12.0, `types-boto3-bedrock-runtime` and other `mypy-boto3-builder` packages migrated to PEP 561 standard packages. This means older `mypy` configurations might need adjustment, though most modern setups will handle it seamlessly. Python 3.8 support was also removed.
fix
Ensure your `mypy` configuration is up-to-date. If using Python 3.8, you must use an older version of `types-boto3-bedrock-runtime` or upgrade to Python 3.9+.
affects: >=8.12.0
breakingIn version 8.9.0, there were breaking changes to how TypeDef names are generated, leading to shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). While this example is not for Bedrock Runtime, it indicates a pattern that might affect specific Bedrock Runtime TypeDefs in future updates if their names become redundant.
fix
If encountering `NameError` or `ImportError` for TypeDefs, check the changelog for the specific version for renaming conventions and adjust your imports/references accordingly.
affects: >=8.9.0
gotchaThis package provides only type stubs for static analysis and does not contain any runtime code. You must have the actual `boto3` library installed for your application to run.
fix
Always install `boto3` alongside `types-boto3-bedrock-runtime`: `pip install boto3 types-boto3-bedrock-runtime`.
affects: all
gotchaDirectly importing from `types_boto3_bedrock_runtime` at runtime (e.g., `from types_boto3_bedrock_runtime.client import BedrockRuntimeClient`) can lead to `ModuleNotFoundError` or other issues if the stub package is not designed for runtime import, or simply adds unnecessary overhead. The stubs are meant for static checkers like `mypy`.
fix
Always wrap imports of types from `types-boto3-*` packages within an `if TYPE_CHECKING:` block. This ensures they are only considered by type checkers and are skipped at runtime.
affects: all
Upgrade
Version history
1.43.30latest on PyPI · released Jun 15, 2026
Audit
Dependencies
boto3requiredThis package provides type stubs for `boto3`. `boto3` must be installed for runtime execution.
mypyoptionalStatic type checker that consumes these type annotations.
typing-extensionsoptionalRequired for Python versions < 3.11 for certain typing features.
Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
types-boto3-bedrock-runtime — pip install types-boto3-bedrock-runtime · libregistry