Skip to main content
The simplest voice-agent pattern: let the agent finish thinking, then hand the final text to stream_tts_openai for narration. This is ideal when you only care about the final answer, not intermediate tokens.

Step 1: Install dependencies

Step 2: Build the agent

Use any LiteLLM-compatible model. Here we use a quantitative trading agent.

Step 3: Run the agent

The agent runs to completion and returns the full response as a string.

Step 4: Stream the result through TTS

stream_tts_openai accepts a list of strings and streams them through OpenAI’s TTS engine. With stream_mode=True, audio chunks play as they’re synthesised.

Full example

When to use this pattern

  • You only need to narrate the final answer.
  • Latency to first audio is not critical (you wait for the agent to finish before any speech).
  • Simplicity wins — no callback wiring, no flush() calls.
For sentence-by-sentence narration as the agent generates, see Streaming Voice Agent.