Registry /
type-stubs / mypy-boto3-bedrock-agent-runtime
Install & Compatibility
Where this runs
tested against v1.43.73 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 52.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.7s · import 0.000s · 53MB
51MB installed
● package 51MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
BedrockAgentRuntimeClient
✓ from mypy_boto3_bedrock_agent_runtime.client import BedrockAgentRuntimeClient
InvokeAgentRequestRequestTypeDef
✓ from mypy_boto3_bedrock_agent_runtime.type_defs import InvokeAgentRequestRequestTypeDef
✗ from mypy_boto3_bedrock_agent_runtime.type_defs import InvokeAgentRequestTypeDef
Since `mypy-boto3-builder` 8.9.0, TypeDefs that conflict with method names (e.g., `InvokeAgent`) are renamed with suffixes like `RequestRequestTypeDef` or `RequestExtraTypeDef` to ensure unique names.
This quickstart demonstrates how to use the `mypy-boto3-bedrock-agent-runtime` stubs to type-hint your `boto3` Bedrock Agent Runtime client. It shows how to retrieve a type-hinted client, prepare an `InvokeAgent` request with `TypeDef` annotations, and process the streaming response from an AWS Bedrock Agent. Make sure `boto3` is installed and configure your AWS credentials and region.
import boto3
from typing import TYPE_CHECKING, Dict, Any
import os
# These are for type checking only, not actual runtime imports
if TYPE_CHECKING:
from mypy_boto3_bedrock_agent_runtime.client import BedrockAgentRuntimeClient
from mypy_boto3_bedrock_agent_runtime.type_defs import InvokeAgentRequestRequestTypeDef, InvokeAgentResponseTypeDef
def get_bedrock_agent_runtime_client() -> "BedrockAgentRuntimeClient":
"""
Returns a type-hinted Bedrock Agent Runtime client.
"""
# In a real application, consider using environment variables or a config file
# for region and credentials.
# For this example, we'll assume region is set via AWS_DEFAULT_REGION or similar.
return boto3.client("bedrock-agent-runtime")
def invoke_agent_example():
client: BedrockAgentRuntimeClient = get_bedrock_agent_runtime_client()
# Replace with your actual Agent ID and Alias ID
# It's recommended to set these as environment variables (e.g., BEDROCK_AGENT_ID)
agent_id = os.environ.get("BEDROCK_AGENT_ID", "YOUR_AGENT_ID")
agent_alias_id = os.environ.get("BEDROCK_AGENT_ALIAS_ID", "YOUR_AGENT_ALIAS_ID")
session_id = "test-session-123" # A unique identifier for the session
input_text = "What is the weather like in Seattle?"
if agent_id == "YOUR_AGENT_ID" or agent_alias_id == "YOUR_AGENT_ALIAS_ID":
print("Please set BEDROCK_AGENT_ID and BEDROCK_AGENT_ALIAS_ID environment variables to run this example.")
print("You can find these in the AWS Bedrock Agents console.")
return
request_params: InvokeAgentRequestRequestTypeDef = {
"agentId": agent_id,
"agentAliasId": agent_alias_id,
"sessionId": session_id,
"inputText": input_text,
"enableTrace": True, # Set to False for production to reduce logging
}
print(f"Invoking agent with input: '{input_text}'")
try:
response: InvokeAgentResponseTypeDef = client.invoke_agent(**request_params)
# Process the response stream
response_body = response.get("completion")
if response_body:
print("Agent response:")
for event in response_body:
if "chunk" in event:
chunk = event["chunk"]
text = chunk.get("bytes").decode("utf-8")
print(f" {text}", end="")
print("\n") # Newline after all chunks
else:
print("No completion received.")
except client.exceptions.ResourceNotFoundException as e:
print(f"Error: Agent or Alias not found. Ensure 'BEDROCK_AGENT_ID' and 'BEDROCK_AGENT_ALIAS_ID' are correct. {e}")
except client.exceptions.ValidationException as e:
print(f"Validation Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
if __name__ == "__main__":
invoke_agent_example()
Debug
Known issues
breakingPython 3.8 is no longer supported. Packages built with `mypy-boto3-builder` version 8.12.0 and later (including `mypy-boto3-bedrock-agent-runtime` versions 1.42.3+) explicitly dropped support for Python 3.8.fixUpgrade your Python environment to version 3.9 or higher.
affects: mypy-boto3-builder >= 8.12.0 (and dependent mypy-boto3-* packages)
breakingTypeDef names might have changed to avoid conflicts. For example, `CreateDistributionRequestTypeDef` might become `CreateDistributionRequestRequestTypeDef` if a method with the same name exists.fixReview your `TypeDef` imports after upgrading `mypy-boto3-builder` or the specific service stub. Consult the latest generated stub files for the exact type definitions (e.g., in `mypy_boto3_bedrock_agent_runtime.type_defs.pyi`).
affects: mypy-boto3-builder >= 8.9.0 (and dependent mypy-boto3-* packages)
gotchaThis library provides only type annotations, not the actual `boto3` implementation. You must install `boto3` separately for your code to run.fixEnsure `boto3` is installed alongside `mypy-boto3-bedrock-agent-runtime` (e.g., `pip install boto3 mypy-boto3-bedrock-agent-runtime`).
affects: All versions
gotchaFor optimal type checking, the `mypy-boto3-*` stub package version should closely match your installed `boto3` version. Significant version discrepancies can lead to incorrect type errors or missed valid types.fixKeep `mypy-boto3-*` packages updated with your `boto3` version. If `boto3` is updated, ensure `mypy-boto3-*` is also updated to the corresponding version.
affects: All versions
Upgrade
Version history
1.43.73latest on PyPI · released Aug 17, 2026
Audit
Dependencies
boto3requiredThis package provides type hints for boto3, which is the actual AWS SDK for Python. Boto3 must be installed to use the Bedrock Agent Runtime service at runtime.
mypyoptionalMypy is the most common static type checker used with these stubs. It is required to leverage the type annotations.
typing-extensionsoptionalRequired for some type features on older Python versions (<3.9) by mypy-boto3-builder.