AWS Nova Sonic
Real-time speech-to-speech with Amazon Nova Sonic on Bedrock through AWSNovaSonicLLMService, with tools and session continuation.
Overview
AWSNovaSonicLLMService streams the user's audio to Amazon Nova Sonic on Bedrock
(InvokeModelWithBidirectionalStream) and returns spoken audio, transcripts and tool calls, so
one service replaces the STT, LLM and TTS stages of a pipeline.
AWSNovaSonicLLMService: the session, withAWSNovaSonicLLMSettingsandAudioConfig.AWSNovaSonicLLMAdapter: converts theLLMContexthistory and tools to Nova Sonic's events.SessionContinuationParams: hands the conversation to a new session before Nova Sonic's session time limit, buffering audio so nothing is lost.
Upstream page
Pipecat's documentation for the same service.
Source
packages/aws/src/nova_sonic/llm.ts, session_continuation.ts and bidirectional_stream.ts.
Nova Sonic docs
Voices, events, tools and limits.
Installation
bun add @pipedog/awsimport { AudioConfig, AWSNovaSonicLLMService } from "@pipedog/aws/nova_sonic/llm";The default transport needs no AWS SDK. For transport: "http2", also install
@aws-sdk/client-bedrock-runtime (an optional peer dependency).
Prerequisites
-
Access to Nova Sonic in the Bedrock console, in a region that offers it.
-
An IAM identity allowed
bedrock:InvokeModelWithBidirectionalStream. -
Keys, in this order of precedence:
accessKeyId,secretAccessKeyandsessionToken.- The
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYandAWS_SESSION_TOKENenvironment variables. - A
credentialsProviderfunction, called for every new session.
The region comes from
region, elseAWS_REGION, elseus-east-1.
AWSNovaSonicLLMService
Configuration
Prop
Type
Settings
Runtime-updatable settings, passed as settings: new AWSNovaSonicLLMService.Settings({...}).
| Setting | Type | Default | Description |
|---|---|---|---|
model | string | "amazon.nova-2-5-sonic" | Bedrock model ID. |
voice | string | "matthew" | Voice ID. |
systemInstruction | string | null | null | System prompt, sent when the session starts. |
temperature | number | 0.7 | Sampling temperature. |
maxTokens | number | 1024 | Maximum tokens per response. |
topP | number | 0.9 | Top-p sampling. |
endpointingSensitivity | "LOW" | "MEDIUM" | "HIGH" | null | null | How quickly Nova Sonic decides the user stopped speaking. |
AudioConfig
Prop
Type
Defaults: 16 kHz 16-bit mono in, 24 kHz 16-bit mono out.
Usage
import { AudioConfig, AWSNovaSonicLLMService } from "@pipedog/aws/nova_sonic/llm";
import { SessionContinuationParams } from "@pipedog/aws/nova_sonic/session_continuation";
const llm = new AWSNovaSonicLLMService({
// Or leave these out to read the AWS_* environment variables.
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: "us-east-1",
settings: new AWSNovaSonicLLMService.Settings({
voice: "tiffany",
systemInstruction: "You are a friendly voice assistant. Keep answers short.",
endpointingSensitivity: "MEDIUM",
}),
audioConfig: new AudioConfig({ inputSampleRate: 16000, outputSampleRate: 24000 }),
// Hand the conversation to a fresh session before Nova Sonic's time limit.
sessionContinuation: new SessionContinuationParams({ enabled: true }),
});To use HTTP/2 through the AWS SDK, as upstream does:
// Upstream's transport: HTTP/2 through the AWS SDK (Node and Bun only).
// Needs `@aws-sdk/client-bedrock-runtime`.
const http2Llm = new AWSNovaSonicLLMService({
region: "us-east-1",
transport: "http2",
});Notes
- Nova Sonic detects turns itself. User and bot transcripts are pushed as transcription and
LLMTextFrames, and audio asTTSAudioRawFrames. - Tools from the context (or
tools) are sent when the session starts. Tool calls run through the usual function-call flow, and results go back astoolResultevents. - With
sessionContinuation, a new session is opened ahead of the time limit (transitionThresholdSeconds) and takes over at the next turn boundary, with the conversation history and buffered user audio. - The JSON events on the wire are upstream's, character for character. Float settings use JS
formatting, so
1.0is sent as1.
Runtime notes
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/aws/package.json: ✅ means the compat smoke test passes on that runtime.
- The default transport is Bedrock's WebSocket endpoint for
InvokeModelWithBidirectionalStream, the one the AWS SDK for JavaScript uses in browsers. pipedog presigns the URL and signs each event with SigV4 on WebCrypto, so it runs on Bun, Node, Deno and Cloudflare Workers. transport: "http2"loads@aws-sdk/client-bedrock-runtimeon connect and uses Node'shttp2, as upstream does: Node and Bun only.clientFactoryreplaces the stream client entirely (for tests or another transport), andendpointUrlchanges the host.- Upstream requires the keys; here they are optional, with the environment and
credentialsProvideras fallbacks. - Not ported: the deprecated
Paramsclass and themodel,voiceId,paramsandsystemInstructionconstructor options. UsesettingsandaudioConfig.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).