Skip to main content

AWSBedrockLLM

AWS Bedrock LLM provider (Converse API). Streams text generation and function/tool calling from any Bedrock-hosted model (Amazon Nova, Anthropic Claude, Meta Llama, Mistral, Google Gemma).

Constructor

model
string
Bedrock model id or inference profile ARN. Falls back to BEDROCK_INFERENCE_PROFILE_ARN. Default: 'amazon.nova-lite-v1:0'.
region
string
AWS region for Bedrock Runtime. Falls back to AWS_DEFAULT_REGION / AWS_REGION, then 'us-east-1'.
awsAccessKeyId
string
Falls back to the AWS_ACCESS_KEY_ID env var.
awsSecretAccessKey
string
Falls back to the AWS_SECRET_ACCESS_KEY env var.
awsSessionToken
string
Falls back to the AWS_SESSION_TOKEN env var.
temperature
number
Sampling temperature. Default: 0.7.
maxOutputTokens
number
Max tokens generated per response. Default: 1024. (Legacy maxTokens/max_tokens also accepted.)
topP
number | null
Nucleus sampling probability mass. Default: null.
topK
number | null
Top-K tokens considered (sent via additional request fields; model support varies). Default: null.
stopSequences
string[] | string | null
Sequences that stop generation; a string or list. Default: null.
toolChoice
string
'auto', 'required', 'none', or a tool name. Default: 'auto'.
cacheSystem
boolean | null
Add a prompt-cache checkpoint after the system prompt. Default: null.
cacheTools
boolean | null
Add a prompt-cache checkpoint after the tool definitions. Default: null.
stripThinking
boolean | null
Remove <thinking>...</thinking> spans from the streamed text. Default: null (provider default).
textToolCalls
boolean | null
Parse function calls a model prints as plain text instead of native Converse tool use. Default: null (auto).
additionalRequestFields
Record<string, any> | null
Extra additionalModelRequestFields merged into the Converse request. Default: null.

cancelCurrentGeneration

Cancel the in-flight generation for the current session, if any.

chat

Stream a completion for the given messages, yielding LLMResponse chunks.
returns
AsyncIterator<LLMResponse>

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

removeAllListeners

event
string