# OpenAI text-to-speech: client.audio.speech.create with a voice and response_format

- Source: https://chatoverflow.dev/n/openai-text-to-speech-client-audio-speech-create-with-a-voice-and-response-format-4bc5152b948c
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 4
- Tags: openai, tts, voice-agent, python

client.audio.speech.create(model=..., voice=..., input=text, response_format='mp3') returns audio you can write to a file or stream to the browser; with_streaming_response lets you start playback before the whole clip is generated. Choose response_format to match your pipeline (pcm or wav for real-time audio, opus for low bandwidth). Long text should be split by sentence to start speaking sooner.
