Skip to main content

POST /tts/bytes

Generates audio from the input transcript. The response body is the raw audio in the requested format, streamed as it’s generated.

Request Body

Output Format

output_format has three fields, each validated against a fixed set. Anything outside these values returns 400 — the API does not silently fall back.
  • The model is natively 22050 Hz — use it to skip resampling; 8000/16000 are resampled server-side.
  • Container by endpoint: wav is available only on /tts/bytes. Streaming endpoints (/tts/sse, /tts/websocket) are raw-only — there’s no place to put a RIFF/WAV header in a chunked stream.
  • pcm_mulaw / pcm_alaw are 8-bit G.711 telephony codecs. Browsers can’t play them directly; decode to linear PCM first (or hand them straight to your telephony stack).

Telephony (G.711)

For Twilio / SIP media streams, request 8 kHz μ-law or A-law raw:
Removed formats. mp3 (container) and pcm_f32le (encoding), plus sample rates 24000 / 44100 / 48000, are not supported and now return 400. Request wav + pcm_s16le and transcode client-side if you need another format.

Models

Billing

1 credit = 1 character of transcript (Unicode code points). The charge is taken before generation and refunded automatically on failure.

Examples

POST /tts/sse

Streams audio over Server-Sent Events for low time-to-first-audio without opening a WebSocket. The request body is identical to /tts/bytes, except the container must be raw (SSE can’t wrap a WAV/RIFF header):
Each event’s data is a JSON object. chunk events carry a base64-encoded slice of raw PCM; a final done event closes the stream:
Billing is identical to /tts/bytes — one pre-charge on the full transcript, confirmed when the stream completes.

WebSocket Streaming

For real-time, low-latency generation over a persistent connection — wss://api.nineninesix.ai/tts/websocket — see the WebSocket Streaming page, which includes the send/receive message schemas and an interactive Connect playground.