Overview
If you’re already using Realtime TTS, Realtime Router enables you to optimize and combine your LLM requests with Realtime Text-to-Speech in a single request. Instead of managing two separate API calls (one for text generation, one for speech synthesis), you send one request and receive both text and audio back. Both streaming and non-streaming modes are supported. In streaming mode, Realtime Router handles the entire pipeline: it intelligently routes your prompt to the best LLM, streams the generated text through an optimized chunking engine, and sends each chunk to the TTS engine as it’s produced. The result is low-latency voice output — you hear the first audio well before the LLM finishes generating the full response. In non-streaming mode, the complete audio and transcript are returned together once the full response is ready. This is ideal for:- Voice assistants and conversational agents
- Real-time narration and read-aloud features
- Accessibility-first applications
- Any workflow where your users hear AI responses instead of (or in addition to) reading them
Quick Start
Add theaudio parameter to any chat completions request to enable TTS. You’ll receive both the text response and audio data in the same stream.
- Route your prompt to your preset Inworld Route (or your chosen model)
- Stream text chunks to Inworld TTS as they’re generated
- Return both text and audio in the SSE stream
Audio Parameters
Theaudio object controls voice synthesis:
Default Audio Output
Streaming Response Format
When streaming is enabled ("stream": true), the response is delivered as Server-Sent Events (SSE). Each event is a JSON object in the data field.
When TTS is active, text is delivered through delta.audio.transcript. Audio data and its corresponding transcript are sent together via delta.audio:
Text and audio are chunked independently. Text is chunked at natural sentence boundaries, while audio is chunked at fixed byte sizes. This means a single
transcript value may span multiple audio chunks. The transcript for a text segment is attached to the first audio chunk of that segment — subsequent audio chunks for the same segment will contain only data without a transcript field.Non-Streaming Response
Without streaming ("stream": false), the full audio and transcript are returned in the message.audio object:
When TTS is active,
message.content is empty. The full text is available in message.audio.transcript.Use Any LLM
Theaudio parameter works with any model available through Inworld Router. The LLM generates text, and Inworld Router handles the TTS conversion separately — so your choice of voice is independent of your choice of model. See the Models API for a full list of supported LLM models.
Combine with Smart Routing Features
All Inworld Router capabilities work alongside TTS:Failover with Voice
If your primary model is unavailable, Inworld Router fails over to a backup — and the voice output continues seamlessly:Cost-Optimized Voice Responses
Route to the cheapest model while still getting audio output:Optimized Chunking
Inworld Router includes a built-in text chunking engine optimized for TTS. Rather than waiting for the LLM to finish generating the full response, the router:- Buffers incoming tokens from the LLM
- Detects natural sentence and clause boundaries
- Sends each chunk to the TTS engine as soon as it’s ready
Tool Calling
Tool calls (function calling) work alongside TTS. When the LLM decides to call a tool, the tool call is returned as standarddelta.tool_calls chunks (no audio is generated for that turn). Once you execute the tool and send the result back with TTS enabled, the final response is spoken.
Tools + Voice Example
Python Example
JavaScript / Node.js Example
Next Steps
- OpenAI Compatibility — use Inworld Router with the OpenAI SDK
- Cost Optimizer — route by query complexity to reduce costs
- Failover System — build a resilient multi-provider setup
- Extra Body Parameters — all available
sort,models, andignoreoptions