Skip to main content

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 the audio parameter to any chat completions request to enable TTS. You’ll receive both the text response and audio data in the same stream.
That’s it. Inworld Router will:
  1. Route your prompt to your preset Inworld Route (or your chosen model)
  2. Stream text chunks to Inworld TTS as they’re generated
  3. Return both text and audio in the SSE stream

Audio Parameters

The audio 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

The audio 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.
This combines Inworld Router’s intelligent model selection with TTS — you get the fastest available LLM and voice output in one call.

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:
If GPT-5 fails, the request falls over to Claude or Gemini — and the same voice (Dennis) is used regardless of which model generates the text.

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:
  1. Buffers incoming tokens from the LLM
  2. Detects natural sentence and clause boundaries
  3. Sends each chunk to the TTS engine as soon as it’s ready
This pipeline significantly reduces Time to First Audio (TTFA) — your users start hearing the response while the LLM is still generating text. The chunking is tuned for natural-sounding speech: it avoids breaking mid-word or mid-phrase, producing smooth, conversational audio.

Tool Calling

Tool calls (function calling) work alongside TTS. When the LLM decides to call a tool, the tool call is returned as standard delta.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