
POST /v1/audio/speech supports raw audio streaming, SSE streaming, and buffered audio.
Set stream to true and stream_format to audio. The response body contains chunked audio bytes.
curl --no-buffer https://api.teenage.works/v1/audio/speech \
-H "Authorization: Bearer tw_live_..." \
-H "Content-Type: application/json" \
-d '{"input":"Start playback as audio arrives.","language":"en","response_format":"mp3","stream":true,"stream_format":"audio"}' \
--output speech.mp3| Format | Content type |
|---|---|
pcm | audio/L16;rate={sample_rate};channels=1 |
mp3 | audio/mpeg |
Set stream_format to sse. Each audio.delta contains a base64 audio chunk; the final audio.done reports the number of chunks.
text
event: audio.delta
data: {"type":"audio.delta","index":0,"delta":"<base64>","ttfa_ms":123.45}
event: audio.done
data: {"type":"audio.done","chunks":12}ttfa_ms appears only on the first delta.
Set stream to false to receive the complete audio body.
| Format | Content type |
|---|---|
pcm | audio/L16;rate={sample_rate};channels=1 |
mp3 | audio/mpeg |
wav | audio/wav |
| Header | Meaning |
|---|---|
x-request-id | Unique request identifier |
x-teenageworks-language | Canonical language code used |
x-teenageworks-representation | Text representation sent to the model |
x-teenageworks-sample-rate | Output sample rate |
x-teenageworks-quality | Applied quality profile |
x-teenageworks-generation-ms | Total generation time on buffered responses |
cache-control | no-store |
On this page