Create a new agent in your browser using this model
Overview
Cartesia text-to-speech is available in LiveKit Agents through LiveKit Inference and the Cartesia plugin. Pricing for LiveKit Inference is available on the pricing page.
| Model ID | Languages |
|---|---|
| cartesia/sonic-3 | endeesfrjaptzhhikoitnlplrusvtrtlbgroarcselfihrmsskdataukhunovibnthhekaidteguknmlmrpa |
| cartesia/sonic-2 | enfrdeesptzhjahiitkonlplrusvtr |
| cartesia/sonic-turbo | enfrdeesptzhjahiitkonlplrusvtr |
| cartesia/sonic | enfrdeesptzhjahiitkonlplrusvtr |
LiveKit Inference
Use LiveKit Inference to access Cartesia TTS without a separate Cartesia API key.
Usage
To use Cartesia, pass a descriptor with the model and voice to the tts argument in your AgentSession:
from livekit.agents import AgentSessionsession = AgentSession(tts="cartesia/sonic-3:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc",# ... llm, stt, vad, turn_detection, etc.)
import { AgentSession } from '@livekit/agents';session = new AgentSession({tts: "cartesia/sonic-3:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc",// ... llm, stt, vad, turn_detection, etc.});
Parameters
To customize additional parameters, use the TTS class from the inference module:
from livekit.agents import AgentSession, inferencesession = AgentSession(tts=inference.TTS(model="cartesia/sonic-3",voice="9626c31c-bec5-4cca-baa8-f8ba9e84c8bc",language="en",extra_kwargs={"speed": 1.5,"volume": 1.2,"emotion": "excited"}),# ... tts, stt, vad, turn_detection, etc.)
import { AgentSession } from '@livekit/agents';session = new AgentSession({tts: new inference.TTS({model: "cartesia/sonic-3",voice: "9626c31c-bec5-4cca-baa8-f8ba9e84c8bc",language: "en",modelOptions: {speed: 1.5,volume: 1.2,emotion: "excited"}}),// ... tts, stt, vad, turn_detection, etc.});
stringRequiredThe model ID from the models list.
stringRequiredSee voices for guidance on selecting a voice.
stringOptionalLanguage code for the input text. If not set, the model default applies.
dictOptionalAdditional parameters to pass to the Cartesia TTS API, including emotion, speed, and volume. See the provider's documentation for more information.
In Node.js this parameter is called modelOptions.
Voices
LiveKit Inference supports all of the default "Cartesia Voices" available in the Cartesia API. You can explore the available voices in the Cartesia voice library (free account required), and use the voice by copying its ID into your LiveKit agent session.
Custom Cartesia voices, including voice cloning, are not yet supported in LiveKit Inference. To use custom voices, create your own Cartesia account and use the Cartesia plugin for LiveKit Agents instead.
The following is a small sample of the Cartesia voices available in LiveKit Inference.
Customizing pronunciation
Cartesia TTS allows you to customize pronunciation using Speech Synthesis Markup Language (SSML). To learn more, see Specify Custom Pronunciations.
Transcription timing
Cartesia TTS supports aligned transcription forwarding, which improves transcription synchronization in your frontend. Set use_tts_aligned_transcript=True in your AgentSession configuration to enable this feature. To learn more, see the docs.
Plugin
Use the Cartesia plugin to connect directly to Cartesia's TTS API with your own API key.
Installation
Install the plugin from PyPI:
uv add "livekit-agents[cartesia]~=1.4"
pnpm add @livekit/agents-plugin-cartesia@1.x
Authentication
The Cartesia plugin requires a Cartesia API key.
Set CARTESIA_API_KEY in your .env file.
Usage
Use Cartesia TTS within an AgentSession or as a standalone speech generator. For example, you can use this TTS in the Voice AI quickstart.
from livekit.plugins import cartesiasession = AgentSession(tts=cartesia.TTS(model="sonic-3",voice="f786b574-daa5-4673-aa0c-cbe3e8534c02",)# ... llm, stt, etc.)
import * as cartesia from '@livekit/agents-plugin-cartesia';const session = new voice.AgentSession({tts: cartesia.TTS(model: "sonic-3",voice: "f786b574-daa5-4673-aa0c-cbe3e8534c02",),// ... llm, stt, etc.});
Parameters
This section describes some of the available parameters. See the plugin reference links in the Additional resources section for a complete list of all available parameters.
stringOptionalDefault: sonic-3ID of the model to use for generation. See supported models.
string | list[float]OptionalDefault: f786b574-daa5-4673-aa0c-cbe3e8534c02ID of the voice to use for generation, or an embedding array. See official documentation.
stringOptionalDefault: enLanguage of input text in ISO-639-1 format. For a list of languages support by model, see supported models.
stringOptionalSee Emotion Controls for Sonic 3 for supported values.
floatOptionalDefault: 1Speed of the speech, where 1.0 is the default speed. See Speed and Volume Controls for Sonic 3 for more information.
floatOptionalDefault: 1Volume of the speech, where 1.0 is the default volume. See Speed and Volume Controls for Sonic 3 for more information.
Additional resources
The following resources provide more information about using Cartesia with LiveKit Agents.