Basic Generation
Generate complete audio and receive it all at once:Playing Audio in Browser
ulaw_8000 or
alaw_8000, consume audio.audio or decoded chunk bytes as raw G.711 data.
Streaming Audio
Receive audio chunks as they are generated for lower latency:Streaming to a Node.js Readable (Vapi / HTTP endpoints)
For server-side integrations that expect a Node.jsReadable stream — such as Vapi custom TTS endpoints or Express/Fastify handlers — use client.tts.toReadable() instead of wiring onChunk manually.
toReadable() avoids a common race-condition: the stream object is returned before any audio arrives, so you can safely pipe() or attach listeners immediately.
Processing Audio Chunks
Word Timestamps
Request word-level time alignments alongside audio. Useful for subtitle synchronization, lip-sync, and barge-in handling.With Generate
With Streaming
Models
List Available Models
Utility Functions
base64ToArrayBuffer
Convert base64 string to ArrayBuffer:decodePCM16
Convert base64 PCM16 to Float32Array for Web Audio API:createWavFile
Create a WAV file from PCM16 data:createWavBlob
Create a playable Blob from PCM16 data:client.tts.toReadable (Node.js only)
Convert a TTS stream directly to a Node.jsReadable for use in HTTP handlers, pipelines, and server-side integrations. See Streaming to a Node.js Readable for a full example.
For real-time LLM pipelines, use Streaming Sessions instead of one-shot
stream(). Input text handling is covered in Text Normalization.