Does livekit support nova sonic 2 voices ? If yes,...
# ask-ai
s
Does livekit support nova sonic 2 voices ? If yes, how to use it
t
Thanks for reaching out, Nishant. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether LiveKit supports "Nova Sonic 2" voices and how to use them. • LiveKit supports Amazon Nova Sonic via the AWS Bedrock realtime plugin for bidirectional speech. There is no mention of a specific model named "Nova Sonic 2" in the LiveKit docs, so support for a version called "Nova Sonic 2" is not confirmed. To use Amazon Nova Sonic with LiveKit: 1. Install the AWS plugin with the realtime extra:
Copy code
uv add "livekit-plugins-aws[realtime]"
1. Set AWS credentials in your `.env`:
Copy code
AWS_ACCESS_KEY_ID=<your-aws-access-key-id>
   AWS_SECRET_ACCESS_KEY=<your-aws-secret-access-key>
1. Create an AgentSession using the realtime model:
Copy code
from livekit.plugins import aws
   session = AgentSession(
       llm=aws.realtime.RealtimeModel(),
   )
1. Optionally set
voice
and `region`:
Copy code
session = AgentSession(
       llm=aws.realtime.RealtimeModel(
           voice="Sarah",
           region="us-west-2"
       ),
   )
Notes: • Nova Sonic’s VAD-based turn detection is used for realtime interactions. • If by "Nova Sonic 2" you mean a newer AWS model/version, that specific name isn't listed in LiveKit docs. If you can share the exact model name or a link, I can check whether it maps to the supported Nova Sonic integration and show exact parameters to pass. Sources: Amazon Nova Sonic integration guide | LiveKit docs | AWS AI and LiveKit | LiveKit Docs
s
i want to pass different model_id
t
You're asking how to pass a different
model_id
for Nova Sonic. You cannot change Nova Sonic's underlying
model_id
in LiveKit — Nova Sonic is a single realtime speech-to-speech model. You can only customize parameters such as voice and region:
Copy code
from livekit.plugins import aws

session = AgentSession(
    llm=aws.realtime.RealtimeModel(
        voice="Rachel",
        region="us-west-2",
    ),
)
If you need to use a different model_id (a different TTS/STS model or provider), tell me which model or provider you want to use (for example Cartesia, Rime, or a specific AWS Bedrock model name). I can then show which LiveKit plugin supports passing
model_id
and the exact parameters to use. Would you like that? Sources: Amazon Nova Sonic integration guide | LiveKit docs
f
I monkey-patched it, and it works fine. Params seem unchanged. ''' model = aws.realtime.RealtimeModel() model.model_id = "amazon.nova-2-sonic-v1:0" session = AgentSession(llm=model) ''' The initial test sounds great, though it appears to use slightly more tokens usage.
t
Thanks — great to hear your test sounds good. A few quick points about what you did and next steps: • Monkey-patching
model.model_id
can work short-term, but it’s not an officially supported configuration path. That means future plugin changes could break the tweak. • Using a different Bedrock model name may change how input/output are tokenized or billed, which explains the slightly higher token usage you observed. • If you want a safer approach, I can: ◦ Show how to wrap
RealtimeModel
in a small helper that sets
model_id
reliably for your project, or ◦ Recommend alternative plugins/providers that officially accept
model_id
if you need stable, supported model switching. Which option would you prefer, or do you want the helper code now?
f
Can you show me; how to wrap
RealtimeModel
in a small helper that sets
model_id
reliably for your project
t
You're asking for a small helper that wraps
RealtimeModel
and reliably sets
model_id
. Below is a concise Python wrapper you can add to your project to avoid monkey-patching while keeping the change localized and easier to maintain.
Copy code
from livekit.plugins import aws

class RealtimeModelWithId(aws.realtime.RealtimeModel):
    """
    Wrapper around aws.realtime.RealtimeModel that ensures a custom model_id
    is set at initialization time (instead of monkey-patching later).
    """

    def __init__(self, *args, model_id: str | None = None, **kwargs):
        # Pass through other args/kwargs to base implementation
        super().__init__(*args, **kwargs)

        # If a custom model_id is provided, store it on the instance.
        # This mirrors what monkey-patching did but keeps it explicit.
        if model_id is not None:
            self.model_id = model_id

    # Optional: if the plugin uses an internal method to build request params,
    # override it to ensure model_id is included. Example placeholder:
    def _build_request_params(self, *args, **kwargs):
        params = super()._build_request_params(*args, **kwargs)
        # Ensure model_id present in the params if set on the instance
        if hasattr(self, "model_id"):
            params["model_id"] = getattr(self, "model_id")
        return params
Usage:
Copy code
model = RealtimeModelWithId(model_id="amazon.nova-2-sonic-v1:0", voice="Rachel", region="us-west-2")
session = AgentSession(llm=model)
Caveats and notes: • This wrapper keeps the change explicit and local; it’s easier to update if the plugin internals change. • If the plugin constructs Bedrock requests in a different internal method name than
_build_request_params
, replace that method override with the correct internal hook used by the plugin. If you want, share the RealtimeModel source you inspected and I’ll adapt the override to the exact method names. • Expect potential differences in tokenization/billing when using non-default Bedrock model names.