--- id: cartesia version: "4.0.1" license: Apache-2.0 license_treatment: permissive maintenance: active --- # cartesia — The official Python library for the cartesia API License: permissive · Maintenance: active · Downloads: 835.7K/mo ## 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 above — 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 pip install cartesia uv add cartesia poetry add cartesia ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 835.7K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags cartesia text-to-speech api client, python tts library, real-time speech synthesis, streaming audio generation, cartesia sonic api, websocket tts client, async text to speech, text-to-speech, api-client, async-support [View on SkillFed](https://skillfed.io/packages/cartesia) · [View on PyPI](https://pypi.org/project/cartesia/)