Files
livekit-agents/python/livekit-plugins/livekit-plugins-aws
Théo Monnom 09262038db Harden realtime, worker and recording boundaries
Run realtime DST scenarios through production provider bookkeeping, with
asynchronous transcription, provider failures, response correlation and
cross-provider history coverage. Ignore unknown provider messages and
settle pending operations when streams or host tasks disappear.

Make job phases own their operations, preserve token restrictions on
refresh, validate inference options and contain failures at external
boundaries. Remove the duplicate Rust media benchmark.

Compare recordings against independent speaker PCM and keep transcripts,
provider spans and reports on the session audio clock across wall-clock
corrections. Preserve silence duration in Gladia energy filtering.

Add regression tests and document the provider and recording audit
findings, including the remaining backend waveform issue and two
independently reproduced baseline storage DST failures.
2026-11-18 04:07:42 -08:00
..

AWS Plugin for LiveKit Agents

Complete AWS AI integration for LiveKit Agents, including Bedrock, Polly, Transcribe, and realtime speech-to-speech support for Amazon Nova Sonic

What's included:

  • RealtimeModel - Amazon Nova 2.5 Sonic, Nova 2 Sonic, and Nova Sonic 1.0 for speech-to-speech
  • LLM - Powered by Amazon Bedrock, defaults to Nova 2 Lite
  • STT - Powered by Amazon Transcribe
  • TTS - Powered by Amazon Polly

See https://docs.livekit.io/agents/integrations/aws/ for more information.

⚠️ Breaking Change

Default model changed to Nova 2 Sonic: RealtimeModel() now defaults to amazon.nova-2-sonic-v1:0 with modalities="mixed" (was amazon.nova-sonic-v1:0 with modalities="audio").

If you need the previous behavior, explicitly specify Nova Sonic 1.0:

model = aws.realtime.RealtimeModel.with_nova_sonic_1()
# or
model = aws.realtime.RealtimeModel(
    model="amazon.nova-sonic-v1:0",
    modalities="audio"
)

Installation

pip install livekit-plugins-aws

# For Nova Sonic realtime models
pip install livekit-plugins-aws[realtime]

Prerequisites

AWS Credentials

You'll need AWS credentials with access to Amazon Bedrock. Set them as environment variables:

export AWS_ACCESS_KEY_ID=<your-access-key>
export AWS_SECRET_ACCESS_KEY=<your-secret-key>
export AWS_DEFAULT_REGION=us-east-1  # or your preferred region

Getting Temporary Credentials from SSO (Local Testing)

If you use AWS SSO for authentication, get temporary credentials for local testing:

# Login to your SSO profile
aws sso login --profile your-profile-name

# Export credentials from your SSO session
eval $(aws configure export-credentials --profile your-profile-name --format env)

# Verify credentials are set
aws sts get-caller-identity

Alternatively, add this to your shell profile for automatic credential export:

# Add to ~/.bashrc or ~/.zshrc
function aws-creds() {
    eval $(aws configure export-credentials --profile $1 --format env)
}

# Usage: aws-creds your-profile-name

Features

Nova 2 Sonic Capabilities

Amazon Nova 2 Sonic is a unified speech-to-speech foundation model that delivers:

  • Realtime bidirectional streaming - Low-latency, natural conversations
  • Multilingual support - English, French, Italian, German, Spanish, Portuguese, and Hindi
  • Automatic language mirroring - Responds in the user's spoken language
  • Polyglot voices - Matthew and Tiffany can seamlessly switch between languages within a single conversation, ideal for multilingual applications
  • 18 expressive voices - Multiple voices per language with natural prosody
  • Function calling - Built-in tool use and agentic workflows
  • Interruption handling - Graceful handling without losing context
  • Noise robustness - Works in real-world environments
  • Text input support - Programmatic text prompting

Model Selection

from livekit.plugins import aws

# Nova 2.5 Sonic (audio + text input, latest)
model = aws.realtime.RealtimeModel.with_nova_sonic_2_5()

# Nova 2 Sonic (audio + text input, default)
model = aws.realtime.RealtimeModel.with_nova_sonic_2()

# Nova Sonic 1.0 (audio-only, original model)
model = aws.realtime.RealtimeModel.with_nova_sonic_1()

Voice Selection

Voices are specified as lowercase strings. Import SONIC1_VOICES or SONIC2_VOICES type hints for IDE autocomplete.

from livekit.plugins.aws.experimental.realtime import SONIC2_VOICES

model = aws.realtime.RealtimeModel.with_nova_sonic_2(
    voice="carolina"  # Portuguese, feminine
)

Nova 2 Sonic Voice IDs (18 voices)

See official documentation for most up-to-date list and IDs.

  • English (US): tiffany (polyglot), matthew (polyglot)
  • English (UK): amy
  • English (Australia): olivia
  • English (India): kiara, arjun
  • French: ambre, florian
  • Italian: beatrice, lorenzo
  • German: tina, lennart
  • Spanish (US): lupe, carlos
  • Portuguese (Brazil): carolina, leo
  • Hindi: kiara, arjun

Note: Tiffany abd Matthew in Nova 2 Sonic support polyglot mode, seamlessly switching between languages within a single conversation.

Nova Sonic 1.0 Voice IDs (11 voices)

See official documentation for most up-to-date list and IDs.

  • English (US): tiffany, matthew
  • English (UK): amy
  • French: ambre, florian
  • Italian: beatrice, lorenzo
  • German: greta, lennart
  • Spanish: lupe, carlos

Text Prompting with generate_reply()

Nova 2 Sonic supports programmatic text input. This can be used to trigger agent responses or to mix speech and text input within a UI in the same conversation:

await session.generate_reply(
    instructions="Greet the user and introduce your capabilities"
)

instructions vs user_input

The generate_reply() method accepts two parameters with different behaviors:

instructions - System-level commands (recommended):

await session.generate_reply(
    instructions="Greet the user warmly and ask how you can help"
)
  • Sent as a system prompt/command to the model
  • Triggers immediate generation
  • Does not appear in conversation history as user message
  • Use for: Agent-initiated speech, prompting specific behaviors

user_input - Simulated user messages:

await session.generate_reply(
    user_input="Hello, I need help with my account"
)
  • Sent as interactive USER role content
  • Added to Nova's conversation context
  • Triggers generation as if user spoke
  • Use for: Testing, simulating user input, programmatic conversations

When to use each:

  • Agent greetings: Use instructions - agent should speak without user input
  • Guided responses: Use instructions - direct the agent's next action
  • Simulated conversations: Use user_input - test multi-turn dialogs
  • Programmatic user input: Use user_input - inject text as if user spoke

Turn-Taking Sensitivity

Control how quickly the agent responds to pauses:

model = aws.realtime.RealtimeModel.with_nova_sonic_2(
    turn_detection="MEDIUM"  # HIGH, MEDIUM (default), LOW
)
  • HIGH: Fastest response time, optimized for latency. May interrupt slower speakers
  • MEDIUM: Balanced approach with moderate response time. Reduces false positives while maintaining responsiveness (recommended)
  • LOW: Slowest response time with maximum patience, better for hesitant speakers

Complete Example

from livekit import agents
from livekit.agents import Agent, VoiceSession
from livekit.plugins import aws
from dotenv import load_dotenv


load_dotenv()

assistant = Agent(instructions="You are a helpful voice assistant powered by Amazon Nova 2 Sonic.")

server = agents.AgentServer()

@server.rtc_session()
async def entrypoint(ctx: agents.JobContext):
    session = VoiceSession(
        llm=aws.realtime.RealtimeModel.with_nova_sonic_2(
            voice="matthew",
            turn_detection="MEDIUM",
            tool_choice="auto"
        )
    )
    
    await session.start(room=ctx.room, agent=assistant)
    await session.generate_reply(instructions="Greet the user and offer assistance")

if __name__ == "__main__":
    agents.cli.run_app(server)

Pipeline Mode (STT + LLM + TTS)

For more control over individual components, use pipeline mode:

from livekit.agents import VoiceSession, inference
from livekit.plugins import aws

session = VoiceSession(
    stt=aws.STT(),                    # Amazon Transcribe
    llm=aws.LLM(),                    # Nova 2 Lite (default)
    tts=aws.TTS(),                    # Amazon Polly
    vad=inference.VAD(),
)

Nova 2 Lite

Amazon Nova 2 Lite is a fast, cost-effective reasoning model optimized for everyday AI workloads:

  • Lightning-fast processing - Very low latency for real-time conversations
  • Cost-effective - Industry-leading price-performance
  • Multimodal inputs - Text, image, and video (documentation)
  • 1 million token context window - Handle long conversations and complex context (source)
  • Agentic workflows - RAG systems, function calling, tool use
  • Fine-tuning support - Customize for your specific use case

Ideal for pipeline mode where you need fast, accurate LLM responses in voice applications.

Resources