cartesia
The official Python library for the cartesia API
What it is and what it does
Cartesia is a Python client library that wraps the Cartesia REST API, enabling developers to generate speech from text using the Sonic real-time text-to-speech model. It provides both synchronous and asynchronous clients powered by httpx, with full type hints for request and response objects. The library supports streaming inputs via websockets, allowing text fragments to be pushed incrementally—useful for latency-sensitive applications like voice agents that need to synthesize LLM output as it streams.
The package handles common API patterns including error handling, retries, timeouts, and file uploads. It supports multiple output formats (container types, encodings, sample rates) and voice selection. Developers can use either the blocking Cartesia client or AsyncCartesia for concurrent operations, with identical functionality between the two.
Use it for:
- Generate speech audio from text and save to file for playback or distribution.
- Stream text fragments from an LLM to Cartesia over websockets for low-latency voice agent responses.
- Build concurrent text-to-speech pipelines using AsyncCartesia for batch audio generation.
- Integrate real-time speech synthesis into interactive applications with custom voice selection and audio format control.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Cartesia is the official Python client library for the Cartesia REST API, providing synchronous and asynchronous access to text-to-speech generation with websocket support for streaming inputs.
Yes. The package is actively maintained, has low install friction, carries a permissive license, and provides a straightforward typed interface to a modern TTS API. Install it if you need to integrate Cartesia's speech synthesis into a Python application. No known security vulnerabilities and supports Python 3.9 through 3.14.
Install
cartesia on PyPI
pip
pip install cartesiauv
uv add cartesiapoetry
poetry add cartesiaInstalling cartesia
Before you install
Low install friction with a pure-Python wheel and six common runtime dependencies. The package is actively maintained with a recent release and 128 repository stars.
License in practice
Licensed under Apache-2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install cartesia
import os
from cartesia import Cartesia
client = Cartesia(api_key=os.getenv("CARTESIA_API_KEY"))
response = client.tts.generate(
model_id="sonic-latest",
output_format={"container": "wav", "encoding": "pcm_f32le", "sample_rate": 44100},
transcript="Hello world",
voice="e07c00bc-4134-4eae-9ea4-1a55fb45746b",
)
response.write_to_file("output.wav")
Requires a valid Cartesia API key set in the CARTESIA_API_KEY environment variable.
Verify before relying
- Whether the websockets extra dependency (mentioned in install docs) is included in the runtime dependency list or must be installed separately.
- Performance characteristics and latency for real-time streaming use cases.
- Rate limits and quota behavior when generating multiple concurrent audio streams.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — anyio, distro, httpx, pydantic, sniffio, typing-extensions |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 835,744/month — #4,934 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cartesia-4.0.1-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
livekit-plugins-cartesiaIntegrates Cartesia's voice AI services…
permissive · top 5,000 on PyPI
kugelaudioOfficial Python SDK for KugelAudio's…
permissive · top 15,000 on PyPI
livekit-plugins-sonioxIntegrates Soniox speech-to-text and…
permissive · top 15,000 on PyPI
deepgram-sdkOfficial Python SDK for Deepgram's speech…
permissive · top 5,000 on PyPI
gladiaio-sdkA Python SDK for the Gladia speech-to-text API,…
unclear · top 15,000 on PyPI
fish-audio-sdkOfficial Python client for the Fish Audio API,…
permissive · top 15,000 on PyPI
elevenlabsOfficial Python SDK for ElevenLabs…
permissive · top 5,000 on PyPI
gTTSgTTS converts text to speech using Google…
permissive · top 5,000 on PyPI
speechmatics-rtAsync Python client for real-time…
permissive · top 15,000 on PyPI
miniaudioMiniaudio provides Python bindings for…
permissive · top 15,000 on PyPI