Creates a new BedrockModel instance.
Optionaloptions: BedrockModelOptionsOptional configuration for model and client
// Minimal configuration with defaults
const provider = new BedrockModel({
region: 'us-west-2'
})
// With model configuration
const provider = new BedrockModel({
region: 'us-west-2',
modelId: 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
maxTokens: 2048,
temperature: 0.8,
cachePrompt: 'ephemeral'
})
// With client configuration
const provider = new BedrockModel({
region: 'us-east-1',
clientConfig: {
credentials: myCredentials
}
})
Updates the model configuration. Merges the provided configuration with existing settings.
Configuration object with model-specific settings to update
Retrieves the current model configuration.
The current configuration object
Streams a conversation with the Bedrock model. Returns an async iterable that yields streaming events as they occur.
Array of conversation messages
Optionaloptions: StreamOptionsOptional streaming configuration
Async iterable of streaming events
const messages: Message[] = [
{ type: 'message', role: $1, content: [{ type: 'textBlock', text: 'What is 2+2?' }] }
]
const options: StreamOptions = {
systemPrompt: 'You are a helpful math assistant.',
toolSpecs: [calculatorTool]
}
for await (const event of provider.stream(messages, options)) {
if (event.type === 'modelContentBlockDeltaEvent') {
console.log(event.delta)
}
}
Streams a conversation with aggregated content blocks and messages. Returns an async generator that yields streaming events and content blocks, and returns the final message with stop reason and optional metadata.
This method enhances the basic stream() by collecting streaming events into complete ContentBlock and Message objects, which are needed by the agentic loop for tool execution and conversation management.
The method yields:
The method returns:
Array of conversation messages
Optionaloptions: StreamOptionsOptional streaming configuration
Async generator yielding ModelStreamEvent | ContentBlock and returning a StreamAggregatedResult
AWS Bedrock model provider implementation.
Implements the Model interface for AWS Bedrock using the Converse Stream API. Supports streaming responses, tool use, prompt caching, and comprehensive error handling.
Example