Cartesia
Updated
Integrate Cartesia TTS into Conversational AI Engine.
Cartesia provides ultra-fast, low-latency text-to-speech with real-time streaming capabilities, optimized for interactive conversational AI applications.
Info
This integration is fully supported for use with Conversational AI Engine. While it has completed functional validation, it is newer to the platform, and additional provider-specific edge cases may be identified as usage scales across a broader range of applications and workloads.
Sample configuration
The following examples show how to configure Cartesia TTS when starting a conversational AI agent.
from agora_agent import Agent
from agora_agent.agentkit.vendors import CartesiaTTS
# client is your configured Agora client
agent = (
Agent(client)
.with_stt(...) # configure your STT vendor
.with_llm(...) # configure your LLM vendor
.with_tts(CartesiaTTS(
api_key='your-cartesia-key',
model_id='sonic-2',
voice_id='<voice_id>',
))
)import { Agent, CartesiaTTS } from 'agora-agents';
// client is your configured Agora client
const agent = new Agent({ client })
.withStt(/* configure your STT vendor */)
.withLlm(/* configure your LLM vendor */)
.withTts(new CartesiaTTS({
apiKey: 'your-cartesia-key',
modelId: 'sonic-2',
voiceId: '<voice_id>',
}));import "github.com/AgoraIO/agora-agents-go/v2/agentkit/vendors"
// client is your configured Agora client
agent := agentkit.NewAgent(client).WithStt(/* configure your STT vendor */).
WithLlm(/* configure your LLM vendor */).
WithTts(
vendors.NewCartesiaTTS(vendors.CartesiaTTSOptions{
APIKey: "your-cartesia-key",
ModelID: "sonic-2",
VoiceID: "<voice_id>",
}),
)Use the following tts configuration in your request:
"tts": {
"vendor": "cartesia",
"params": {
"api_key": "<your_cartesia_key>",
"model_id": "sonic-2",
"base_url": "wss://api.cartesia.ai",
"voice": {
"mode": "id",
"id": "<voice_id>"
},
"output_format": {
"container": "raw",
"sample_rate": 16000
},
"language": "en"
}
}Caution
The parameters listed on this page are validated for use with Conversational AI Engine. Required parameters must be provided as documented. Any additional parameters are passed through directly to the underlying vendor without validation. For a full list of supported options, refer to the Cartesia TTS documentation.
Key parameters
api_keystringThe Cartesia API key used to authenticate requests. Get your API key from the Cartesia Console.
model_idstringThe identifier of the TTS model to use. For example, sonic-2.
base_urlstringThe WebSocket URL for the Cartesia streaming API. For example, wss://api.cartesia.ai.
voiceobjectVoice configuration object.
modestringVoice selection mode. Use id to select by voice identifier.
idstringThe identifier of the selected voice for speech synthesis.
output_formatobjectAudio output format configuration
containerstringAudio container format for the output stream.
sample_ratenumber- Default value
- 16000
- Possible values
80001600022050240004410048000
Audio sampling rate in Hz
languagestringTarget language for speech synthesis.
