One call turns text into natural-sounding speech. Here's how OpenAI's text-to-speech API works — the models, voices, formats, and streaming — and where it fits in a product.
Written forEngineeringProduct
AudioText-to-SpeechOpenAI
Giving a product a voice used to mean a specialist vendor and a pile of integration. OpenAI's text-to-speech endpoint collapses it to a single call: pass text, get back natural-sounding audio. Here's the shape of it and where it earns its place.
The one call
Text in, audio out
from openai import OpenAI
client = OpenAI()
with client.audio.speech.with_streaming_response.create(
model='tts-1',
voice='alloy',
input='Hello from the audio API.',
) as response:
response.stream_to_file('speech.mp3')
The knobs worth knowing
Models — tts-1 for low latency, tts-1-hd for higher quality; newer steerable models (e.g. gpt-4o-mini-tts) let you direct tone and delivery.
Voices — a set of built-in voices (alloy, echo, fable, onyx, nova, shimmer, and more) with distinct character.
Formats — mp3, opus, aac, flac, wav, and pcm; pick opus for streaming, wav/pcm for low-latency pipelines.
Speed — adjust the speaking rate when you need it faster or slower.
Where it fits
It's ideal for voiceovers, read-aloud and accessibility, audio notifications, and the speech-out half of a voice agent (paired with speech-to-text and an LLM). For full real-time, interruptible voice conversations, a purpose-built realtime or voice-agent stack will serve you better than stitching TTS calls together.
Voice used to be a project. Now it's a function call — which changes what's worth adding a voice to.
Building something with LLMs?
I help teams ship GenAI that’s reliable and cost-efficient.