# cartesia-python

> Official Python library for Cartesia's real-time text-to-speech API

cartesia-python is the official client library for interacting with Cartesia's Sonic text-to-speech models in Python. It supports synchronous and asynchronous HTTP requests alongside WebSocket streaming for low-latency audio generation. It is designed for developers building voice agents and real-time speech applications.

Website: https://github.com/cartesia-ai/cartesia-python

## What it is for

- Stream real-time text-to-speech audio from LLM output over WebSockets
- Generate WAV or PCM voice audio files from text transcripts
- Integrate voice cloning and custom voice playback into Python applications
- Manage and paginate through Cartesia voice datasets and profiles

## Features

- Synchronous and asynchronous clients powered by httpx and optional aiohttp backend
- Full WebSocket streaming support for low-latency chunked audio generation
- Pydantic response models and TypedDict request parameters for editor autocomplete
- Built-in automatic pagination for voice and dataset listing
- Automatic retries with exponential backoff for rate limits and connection errors
- Granular audio formatting controls including container, encoding, and sample rate

## Pricing

Paid. Open-source SDK, requires a paid Cartesia API key

## Details

- Type: GitHub repo
- Category: [AI](https://xiry.app/topics/ai.md)
- Topic: [Text to Speech](https://xiry.app/topics/ai/text-to-speech.md)
- Open source: yes
- Platforms: Code library, API
- For: Python developers building voice agents, audio tools, and AI assistants
- Alternative to: elevenlabs, deepgram, openai
- Tags: tts, text to speech, voice, audio, cartesia, python sdk, websockets

## Why it was saved

- [@svpino, 8 February 2025](https://x.com/svpino/status/1888320663200604319): For integrating voice cloning / voice agents into products in Python.

## Compare

- [Alternatives to ElevenLabs](https://xiry.app/alternatives/elevenlabs.md)

## Related

- [ElevenLabs](https://xiry.app/resources/elevenlabs): AI voice generator, voice cloning, and conversational agent platform (Web app, Freemium)
- [Cartesia Sonic](https://xiry.app/resources/cartesia-sonic): Ultra-low-latency streaming text-to-speech and instant voice cloning model. (AI model, Freemium)
- [Dia](https://xiry.app/resources/dia): Open-source 1.6B text-to-speech model generating multi-speaker dialogue in one pass. (AI model, Open source)
- [Airy](https://xiry.app/resources/airy): Fast, low-cost text-to-speech API and studio for creators and developers (AI model, Freemium)
- [AudioPen](https://xiry.app/resources/audiopen): Converts spoken thoughts into structured, polished writing in customizable styles. (Web app, Freemium)
- [Chatterbox](https://xiry.app/resources/chatterbox): Open-source zero-shot text-to-speech and voice cloning model (AI model, Open source)

Updated 10 October 2026. Page: https://xiry.app/resources/cartesia-python

Make your own library: Xiry takes your saved reels, tweets, Reddit bookmarks and Watch Later videos, makes them searchable and pulls the useful stuff out, like this library. It's invite-only for now; join the waitlist at https://xiry.app/#waitlist.
