Ensure the IAM principal has the bedrock:InvokeModel permission and that the target model has been enabled in the Bedrock console for your region.
Instantiate a boto3 client for the 'bedrock-runtime' service (not 'bedrock') in the desired region.
Construct the request body as a JSON-serializable dict whose schema matches the specific model provider's format (e.g., Anthropic Claude expects an 'anthropic_version' field and a 'messages' array).
Read and decode the response: json.loads(response['body'].read()) to get the completion.
Handle throttling exceptions (ThrottlingException) with exponential backoff, as on-demand throughput can be rate-limited.
Known gotchas
Model IDs in Bedrock use a provider-prefixed format (e.g., 'anthropic.claude-...'); using a bare model name without the provider prefix returns a model not found error.
Not all models are available in all regions; check the Bedrock console for the specific region you target before coding the model ID.
The request body schema differs per model family; using the Anthropic body format against an Amazon Titan model will return a validation error.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp