{"library":"mypy-boto3-bedrock-agent-runtime","title":"Mypy Boto3 Bedrock Agent Runtime Stubs","description":"This library provides PEP 561 type annotations for the `boto3` Bedrock Agent Runtime service. It allows static type checkers like Mypy to validate usage of `boto3.client('bedrock-agent-runtime')`, improving code reliability and developer experience. The current version is 1.42.3 and new versions are released frequently, typically mirroring `boto3` releases and the `mypy-boto3-builder`'s update cadence.","language":"python","status":"active","last_verified":"Thu May 14","install":{"commands":["pip install boto3 mypy-boto3-bedrock-agent-runtime"],"cli":null},"imports":["from mypy_boto3_bedrock_agent_runtime.client import BedrockAgentRuntimeClient","from mypy_boto3_bedrock_agent_runtime.type_defs import InvokeAgentRequestRequestTypeDef"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING, Dict, Any\nimport os\n\n# These are for type checking only, not actual runtime imports\nif TYPE_CHECKING:\n    from mypy_boto3_bedrock_agent_runtime.client import BedrockAgentRuntimeClient\n    from mypy_boto3_bedrock_agent_runtime.type_defs import InvokeAgentRequestRequestTypeDef, InvokeAgentResponseTypeDef\n\ndef get_bedrock_agent_runtime_client() -> \"BedrockAgentRuntimeClient\":\n    \"\"\"\n    Returns a type-hinted Bedrock Agent Runtime client.\n    \"\"\"\n    # In a real application, consider using environment variables or a config file\n    # for region and credentials.\n    # For this example, we'll assume region is set via AWS_DEFAULT_REGION or similar.\n    return boto3.client(\"bedrock-agent-runtime\")\n\ndef invoke_agent_example():\n    client: BedrockAgentRuntimeClient = get_bedrock_agent_runtime_client()\n\n    # Replace with your actual Agent ID and Alias ID\n    # It's recommended to set these as environment variables (e.g., BEDROCK_AGENT_ID)\n    agent_id = os.environ.get(\"BEDROCK_AGENT_ID\", \"YOUR_AGENT_ID\")\n    agent_alias_id = os.environ.get(\"BEDROCK_AGENT_ALIAS_ID\", \"YOUR_AGENT_ALIAS_ID\")\n    session_id = \"test-session-123\" # A unique identifier for the session\n    input_text = \"What is the weather like in Seattle?\"\n\n    if agent_id == \"YOUR_AGENT_ID\" or agent_alias_id == \"YOUR_AGENT_ALIAS_ID\":\n        print(\"Please set BEDROCK_AGENT_ID and BEDROCK_AGENT_ALIAS_ID environment variables to run this example.\")\n        print(\"You can find these in the AWS Bedrock Agents console.\")\n        return\n\n    request_params: InvokeAgentRequestRequestTypeDef = {\n        \"agentId\": agent_id,\n        \"agentAliasId\": agent_alias_id,\n        \"sessionId\": session_id,\n        \"inputText\": input_text,\n        \"enableTrace\": True, # Set to False for production to reduce logging\n    }\n\n    print(f\"Invoking agent with input: '{input_text}'\")\n    try:\n        response: InvokeAgentResponseTypeDef = client.invoke_agent(**request_params)\n\n        # Process the response stream\n        response_body = response.get(\"completion\")\n        if response_body:\n            print(\"Agent response:\")\n            for event in response_body:\n                if \"chunk\" in event:\n                    chunk = event[\"chunk\"]\n                    text = chunk.get(\"bytes\").decode(\"utf-8\")\n                    print(f\"  {text}\", end=\"\")\n            print(\"\\n\") # Newline after all chunks\n        else:\n            print(\"No completion received.\")\n\n    except client.exceptions.ResourceNotFoundException as e:\n        print(f\"Error: Agent or Alias not found. Ensure 'BEDROCK_AGENT_ID' and 'BEDROCK_AGENT_ALIAS_ID' are correct. {e}\")\n    except client.exceptions.ValidationException as e:\n        print(f\"Validation Error: {e}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    invoke_agent_example()\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":"2026-04-25","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-14","installed_version":"1.43.0","pypi_latest":"1.43.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":3.7,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"51.4M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4,"import_time_s":null,"mem_mb":null,"disk_size":"52M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"54.4M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.8,"import_time_s":null,"mem_mb":null,"disk_size":"55M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"45.6M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.2,"import_time_s":null,"mem_mb":null,"disk_size":"46M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"45.4M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":"46M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"50.8M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"boto3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.6,"import_time_s":null,"mem_mb":null,"disk_size":"51M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"boto3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}