AWS SDK for Bedrock Runtime
raw JSON → 0.5.0 verified Mon Apr 27 auth: no python
The aws-sdk-bedrock-runtime library provides a Python client for Amazon Bedrock Runtime, enabling inference with foundation models via the AWS SDK. Version 0.5.0 supports Python 3.12+ and is under active development. Release cadence is monthly or patch-as-needed.
pip install aws-sdk-bedrock-runtime Common errors
error ModuleNotFoundError: No module named 'aws_sdk_bedrock_runtime' ↓
cause The package is not installed or the import uses the wrong name (e.g., hyphen instead of underscore).
fix
Install the package: 'pip install aws-sdk-bedrock-runtime'. Then use underscore in import: 'from aws_sdk_bedrock_runtime import ...'.
error TypeError: Missing required keyword argument 'modelId' ↓
cause The 'InvokeModelCommand' expects 'modelId' as a required argument, not just in the body.
fix
Provide 'modelId' as a keyword argument: InvokeModelCommand(modelId='amazon.titan-text-lite-v1', ...).
Warnings
breaking The package 'aws-sdk-bedrock-runtime' is distinct from the older 'boto3' Bedrock Runtime client and requires Python >=3.12. Existing code using boto3 bedrock-runtime will need rewriting. ↓
fix Migrate from boto3 to this SDK. Replace 'boto3.client("bedrock-runtime")' with 'BedrockRuntimeClient'.
gotcha The import path uses underscores, not hyphens. The package name on PyPI contains hyphens (aws-sdk-bedrock-runtime) but the Python module uses underscores (aws_sdk_bedrock_runtime). ↓
fix Use 'from aws_sdk_bedrock_runtime import ...' not 'from aws-sdk-bedrock-runtime'.
deprecated As of version 0.5.0, the 'InvokeModelCommand' class may be renamed in future releases. Check the latest documentation for command class names. ↓
fix Monitor release notes and update imports when the naming stabilizes.
Imports
- BedrockRuntimeClient wrong
from bedrock_runtime import BedrockRuntimeClientcorrectfrom aws_sdk_bedrock_runtime import BedrockRuntimeClient - InvokeModelCommand wrong
from bedrock_runtime.models import InvokeModelCommandcorrectfrom aws_sdk_bedrock_runtime.models import InvokeModelCommand
Quickstart
import os
from aws_sdk_bedrock_runtime import BedrockRuntimeClient
from aws_sdk_bedrock_runtime.models import InvokeModelCommand
client = BedrockRuntimeClient(region=os.environ.get('AWS_REGION', 'us-east-1'))
resp = client.invoke_model(InvokeModelCommand(modelId='amazon.titan-text-lite-v1', contentType='application/json', accept='application/json', body='{"inputText":"Hello"}'))
print(resp.body)