skillfed

cartesia

The official Python library for the cartesia API

cartesia v4.0.1 835.7K downloads/30d#4,934 on PyPI128
Permissive license Apache-2.0 Active released

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 cartesia

uv

uv add cartesia

poetry

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 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

Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

cartesia text-to-speech api clientpython tts libraryreal-time speech synthesisstreaming audio generationcartesia sonic apiwebsocket tts clientasync text to speech
text-to-speechapi-clientasync-support

More Python Modules packages