ConverseStream
Source:
src/AWS/Bedrock/ConverseStream.ts
Runtime binding for bedrock-runtime:ConverseStream — the streaming
variant of Converse. The response arrives as an event Stream of
ConverseStreamOutput events (messageStart, contentBlockDelta,
messageStop, metadata, …) instead of a single message.
The binding grants the function bedrock:InvokeModelWithResponseStream
(the IAM action streaming operations authorize against) scoped to exactly
the bound models. A model reference may be a foundation-model id, a
cross-region inference profile id (e.g. us.amazon.nova-micro-v1:0), or a
full Bedrock ARN.
Model access is an account entitlement — enable the model in the Bedrock
console (Model access) before invoking, otherwise calls fail with
AccessDeniedException.
Streaming a Conversation
Section titled “Streaming a Conversation”// initconst converseStream = yield* Bedrock.ConverseStream("us.amazon.nova-micro-v1:0");
// runtimeconst result = yield* converseStream({ messages: [{ role: "user", content: [{ text: "Say hello." }] }], inferenceConfig: { maxTokens: 64 },});const events = yield* Stream.runCollect(result.stream ?? Stream.empty);const text = events .map((event) => event.contentBlockDelta?.delta.text ?? "") .join("");