Synthesize speech (streaming, in any of 15 audio formats)
Returns audio bytes. With stream: true (the default) the body uses chunked transfer-encoding and bytes are written as the model produces them, so you can start playing before synthesis finishes. The whole response is ONE continuous file from ONE encoder — concatenate the chunks, do not decode them individually.
Audio defaults to MPEG-2 Layer III (MP3), 24 kHz, mono, 128 kbps, with no Xing/LAME header and no ID3 tag — the body starts at the first audio frame. Set response_format for anything else: mp3, mp3_64, mp3_160, wav, wav24, wav32f, flac, flac24, pcm, pcm_f32, aiff, caf, au, mulaw, alaw. The exact numbers for a given response are echoed in the X-Ditto-Audio-* headers; decode and resample from those rather than assuming a rate. GET /v1/audio/format describes every encoding in full, without authentication.
Streaming and container headers. Formats that carry a length field (wav, aiff, caf, au, flac) write the format’s own UNKNOWN-length value while streaming, because a chunked body cannot be seeked back to and patched. Send stream: false for exact sizes, a Content-Length, and — for flac — a real MD5 in STREAMINFO. The samples are identical either way.
Cost. Hi-fidelity formats bill at 1.2× the normal rate, multiplied by the model’s own weighting — the audio is identical, but the bytes are several times larger. mp3 (the default), mp3_64, mulaw and alaw are unchanged at 1×. Each format’s exact multiplier is in GET /v1/audio/format and in the X-Ditto-Audio-Cost-Multiplier response header.
Aborting the request closes the connection and STOPS server-side generation — cancelling actually saves inference, it does not just stop you reading.
The language actually used is echoed in X-Ditto-Language, with X-Ditto-Language-Inferred: true when it was detected from input rather than supplied.
Every response carries X-Ditto-Quota-Limit, -Used, -Remaining, -Percent and -Reset — billed SECONDS of audio, weighted per model (Kokoro 1.5×, XTTS 3×) and per format — so you can watch the allowance drain without a separate call. Omitted entirely for unmetered accounts.
Request
- Base URL: https://api.ditto.audio (the document declares no server; this is the origin it was published from)
- URL: https://api.ditto.audio/v1/audio/speech
- Auth: HTTP bearer
Request body
Example request
{
"model": "kokoro",
"voice": "kokoro-af-heart",
"input": "The quick brown fox jumps over the lazy dog.",
"language": "en"
}Response
Raw audio bytes (no envelope, no SSE framing) in the requested response_format. Chunked unless stream:false. Defaults to MPEG-2 Layer III, 24000 Hz, mono — the actual encoding is echoed in the X-Ditto-Audio-* headers below.
Changes
No recorded changes to this operation across all 1 revision of this API.