Registry /
llm-agents / livekit-plugins-cartesia
Install & Compatibility
Where this runs
tested against v1.1.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
301MB installed
● package 301MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
cartesia
✓ from livekit.plugins import cartesia
The Cartesia plugin is imported as a module under livekit.plugins.
TTS
✓ from livekit.plugins.cartesia import TTS
✗ from livekit.plugins import TTS
TTS is a class within the cartesia plugin module, not directly under livekit.plugins.
STT
✓ from livekit.plugins.cartesia import STT
✗ from livekit.plugins import STT
STT is a class within the cartesia plugin module, not directly under livekit.plugins.
This quickstart demonstrates how to initialize a LiveKit AgentSession with Cartesia's TTS and STT capabilities. It uses `cartesia.TTS` and `cartesia.STT` classes, requiring `CARTESIA_API_KEY` to be set as an environment variable. A full LiveKit Agent setup also requires `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET`.
import os
import asyncio
from livekit.agents import AgentSession, JobContext, WorkerOptions, cli
from livekit.plugins import cartesia
class CartesiaVoiceAgent:
@cli.agent_handler("voice")
async def agent_handle(self, ctx: JobContext):
session = AgentSession(ctx)
await session.start(
tts=cartesia.TTS(api_key=os.environ.get('CARTESIA_API_KEY', '')),
stt=cartesia.STT(api_key=os.environ.get('CARTESIA_API_KEY', '')),
# Other agent components like LLM, VAD, etc., would be configured here
)
print("Agent started. Listening for speech...")
# Example: Say something to the user
await session.say("Hello! I am a Cartesia-powered voice agent. How can I help you today?")
# In a real agent, you would have a loop to process user input (STT) and generate responses (TTS)
# For demonstration, we'll just keep the session alive briefly.
await asyncio.sleep(60)
if __name__ == "__main__":
# Ensure environment variables are set for LiveKit and Cartesia
# For LiveKit: LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET
# For Cartesia: CARTESIA_API_KEY
# Example of how to run the agent (usually via `livekit-cli run`)
# For local testing, you might need to set up a mock or local LiveKit server
# This quickstart is meant to illustrate the plugin usage, not a full deployment.
# Set dummy values if env vars are missing for local testing to avoid immediate errors
os.environ.setdefault('LIVEKIT_URL', 'wss://your-livekit-server.cloud')
os.environ.setdefault('LIVEKIT_API_KEY', 'SK_YOUR_LIVEKIT_API_KEY')
os.environ.setdefault('LIVEKIT_API_SECRET', 'YOUR_LIVEKIT_API_SECRET')
os.environ.setdefault('CARTESIA_API_KEY', 'YOUR_CARTESIA_API_KEY') # Replace with your actual key
cli.run(WorkerOptions(agent_handles=[CartesiaVoiceAgent().agent_handle]))
Debug
Known issues
breakingLiveKit Agents 1.5.0 introduced significant changes to the `TurnHandlingOptions` API. Old keyword arguments for endpointing and interruption (e.g., `min_endpointing_delay`, `allow_interruptions`) are deprecated and will be removed in future versions. Agents should be updated to use the new dictionary-based `turn_handling` parameter.fixRefactor `AgentSession` initialization to use the `turn_handling` dictionary for all turn detection and interruption settings, instead of deprecated individual keyword arguments. Refer to the LiveKit Agents 1.5.0 changelog for details.
affects: livekit-agents>=1.5.0
gotchaThe `livekit-plugins-cartesia` plugin requires a Cartesia API key. This key must be provided explicitly to the `TTS` and `STT` constructors or set as the `CARTESIA_API_KEY` environment variable. Without it, Cartesia services will fail to authenticate.fixEnsure `os.environ['CARTESIA_API_KEY']` is set, or pass `api_key='YOUR_CARTESIA_API_KEY'` directly to `cartesia.TTS()` and `cartesia.STT()` during initialization.
affects: All versions
gotchaWith livekit-agents 1.4.4, the default Cartesia TTS model was upgraded to 'Sonic 3'. If your application previously relied on an older default Cartesia model without explicitly specifying it, the voice output might change unexpectedly after upgrading LiveKit Agents (and by extension, this plugin's underlying dependencies).fixIf specific voice characteristics are critical, always explicitly define the `model` and `voice` parameters in `cartesia.TTS()` to ensure consistent behavior across updates. For example, `cartesia.TTS(model='sonic-2', ...)` if you intend to use the older default.
affects: livekit-agents>=1.4.4
Errors
Common errors & fixes
livekit.agents._exceptions.APIStatusError: Cartesia STT connection closed unexpectedly
This error often occurs due to intermittent network disconnections with the Cartesia API or if STT processing starts before a user has fully joined the LiveKit session, leading to unexpected websocket closures.
fixImplement retry logic for STT processing and ensure that STT is only initialized or started after the user has successfully joined the session. The `livekit-agents` framework often handles retries, but delaying the STT start can prevent initial issues.
APIError: no audio frames were pushed
This error indicates that the Cartesia TTS plugin failed to synthesize audio for a given text input, often occurring intermittently for valid conversational text.
fixThis can sometimes be transient. Ensure the input text is valid and not empty. If the issue persists, check Cartesia's service status and consider implementing retry mechanisms for TTS synthesis. Updating `livekit-agents` and `livekit-plugins-cartesia` to their latest versions might also help, as patches for this issue have been released.
livekit.agents._exceptions.APIConnectionError: Connection error.
This general connection error can occur if there are network issues preventing communication with the Cartesia API, or if the input text to the TTS/STT service is unexpectedly empty.
fixVerify network connectivity and ensure that the Cartesia API key is correctly configured and has not expired. Also, check that the input text being sent to Cartesia's TTS/STT service is not empty or malformed. Update `livekit-plugins-cartesia` to resolve known issues with empty input text.
TypeError: can't pickle multidict._multidict.CIMultiDictProxy objects
This `TypeError` occurs in LiveKit Agents when using process-based job execution, specifically when `aiohttp` exceptions (from plugins like Cartesia) are logged. The `CIMultiDictProxy` objects within `aiohttp` response headers are not pickleable, causing the logging process to fail.
fixThis is a known issue within `livekit-agents`'s `LogQueueHandler`. A robust fix typically involves sanitizing non-standard attributes in log records before pickling them. Ensure you are using the latest version of `livekit-agents` and `livekit-plugins-cartesia`, as updates may include patches for this logging behavior.
Upgrade
Version history
1.7.1latest on PyPI · released Aug 27, 2026
Audit
Dependencies
livekit-agentsrequiredThis package is a plugin for the LiveKit Agents framework.