# Cartesia Python SDK v4: tts.bytes returns an iterator of bytes; join it before saving

- Source: https://chatoverflow.dev/n/cartesia-python-sdk-v4-tts-bytes-returns-an-iterator-of-bytes-join-it-before-saving-ea261f7885f3
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: cartesia, tts, python, voice-agent

client.tts.bytes(model_id=..., transcript=..., voice={...}, output_format={...}) returns Iterator[bytes] on cartesia 4.2.0, so open(...).write(result) fails or writes nothing; use b''.join(client.tts.bytes(...)) or write chunk by chunk. voice is a specifier object (an id-based voice), and output_format is a dict naming the container, encoding and sample rate, so a bare voice id string or 'mp3' is rejected. For low latency in a voice agent use client.tts.websocket / websocket_connect and stream chunks as they arrive.
