Overview
AWSBedrockLLMService provides access to Amazon’s foundation models including Anthropic Claude and Amazon Nova, with streaming responses, function calling, and multimodal capabilities through Amazon’s managed AI service for enterprise-grade LLM deployment.
AWS Bedrock LLM API Reference
Pipecat’s API methods for AWS Bedrock integration
Example Implementation
Complete example with function calling
AWS Bedrock Documentation
Official AWS Bedrock documentation and features
AWS Console
Access foundation models and manage IAM
Installation
To use AWS Bedrock services, install the required dependencies:Prerequisites
AWS Account Setup
Before using AWS Bedrock LLM services, you need:- AWS Account: Sign up at AWS Console
- IAM User: Create an IAM user with Amazon Bedrock permissions
- Model Access: Request access to foundation models in your AWS region
- Credentials: Set up AWS access keys and region configuration
Required Environment Variables
AWS_ACCESS_KEY_ID: Your AWS access key IDAWS_SECRET_ACCESS_KEY: Your AWS secret access keyAWS_SESSION_TOKEN: Session token (if using temporary credentials)AWS_REGION: AWS region (defaults to “us-east-1”)
Configuration
AWS Bedrock model identifier (e.g.,
"us.anthropic.claude-sonnet-4-5-20250929-v1:0", "us.amazon.nova-pro-v1:0").AWS access key ID. If
None, uses the AWS_ACCESS_KEY_ID environment variable or default credential chain.AWS secret access key. If
None, uses the AWS_SECRET_ACCESS_KEY environment variable or default credential chain.AWS session token for temporary credentials. If
None, uses the AWS_SESSION_TOKEN environment variable.AWS region for the Bedrock service. If
None, uses the AWS_REGION environment variable, defaulting to "us-east-1".Runtime-configurable model settings. See InputParams below.
Custom boto3 client configuration. If
None, uses defaults with 5-minute connect/read timeouts and 3 retry attempts.Request timeout in seconds. Used when
retry_on_timeout is enabled to determine when to retry.Whether to retry the request once if it times out. The retry attempt has no timeout limit.
InputParams
Model inference settings that can be set at initialization via theparams constructor argument, or changed at runtime via UpdateSettingsFrame.
| Parameter | Type | Default | Description |
|---|---|---|---|
max_tokens | int | None | Maximum number of tokens to generate. Must be at least 1. |
temperature | float | None | Sampling temperature (0.0 to 1.0). Lower values are more focused, higher values are more creative. |
top_p | float | None | Top-p (nucleus) sampling (0.0 to 1.0). Controls diversity of output. |
stop_sequences | List[str] | [] | List of strings that stop generation when encountered. |
latency | str | None | Performance mode: "standard" or "optimized". |
additional_model_request_fields | dict | {} | Additional model-specific parameters passed directly to the API. |
None values are omitted from the inference config, letting the Bedrock API use its own defaults. Only parameters that are explicitly set are included in the request. This avoids conflicts with models that don’t allow certain parameter combinations (e.g., temperature and top_p together).Usage
Basic Setup
With Custom Parameters
Updating Settings at Runtime
Model settings can be changed mid-conversation usingUpdateSettingsFrame:
Notes
- Credential chain: If
aws_access_keyandaws_secret_keyare not provided, the service falls back to environment variables and then the standard AWS credential chain (IAM roles, instance profiles, etc.). - No-op tool handling: AWS Bedrock requires at least one tool to be defined when tool content exists in the conversation. The service automatically adds a placeholder tool when needed to prevent API errors.
- Model-specific parameters: Some models (e.g., Claude Sonnet 4.5) don’t allow certain parameter combinations. The service only includes explicitly set parameters in the inference config to avoid conflicts.
- Retry behavior: When
retry_on_timeout=True, the first attempt uses theretry_timeout_secstimeout. If it times out, a second attempt is made with no timeout limit.
Event Handlers
AWSBedrockLLMService supports the following event handlers, inherited from LLMService:
| Event | Description |
|---|---|
on_completion_timeout | Called when an LLM completion request times out |
on_function_calls_started | Called when function calls are received and execution is about to start |