---
title: WebSocket vs REST TTS APIs for Voice Agents
description: Choosing between WebSocket and REST for your streaming TTS API changes your voice agent's latency floor. Here is how to pick the right protocol.
canonical: https://lukeocodes.dev/websocket-vs-rest-tts-voice-agents
type: article
locale: en_GB
published: 2026-08-02T00:00:00.000Z
modified: 2026-08-02T00:00:00.000Z
authors:
  - Luke Oliff
section: Text-to-Speech
tags:
  - Text-to-Speech
  - Voice Agents
  - Streaming
  - API Design
  - Latency
feed: https://lukeocodes.dev/rss.xml
search: https://lukeocodes.dev/search.json?q={query}
schema:
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": WebSite
        "@id": https://lukeocodes.dev/#website
        url: https://lukeocodes.dev
        name: Luke Oliff
        alternateName: lukeocodes
        inLanguage: en
        publisher:
          "@id": https://lukeocodes.dev/authors/luke#person
        description: Personal blog and writing by Luke Oliff — developer relations, voice AI, developer experience.
        potentialAction:
          - "@type": SearchAction
            target:
              "@type": EntryPoint
              urlTemplate: https://lukeocodes.dev/blog/search?q={search_term_string}
            query-input: required name=search_term_string
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
      - "@type": BlogPosting
        "@id": https://lukeocodes.dev/websocket-vs-rest-tts-voice-agents#article
        headline: WebSocket vs REST TTS APIs for Voice Agents
        alternativeHeadline: WebSocket vs REST TTS APIs for Voice Agents
        description: Choosing between WebSocket and REST for your streaming TTS API changes your voice agent's latency floor. Here is how to pick the right protocol.
        datePublished: 2026-08-02T00:00:00.000Z
        dateModified: 2026-08-02T00:00:00.000Z
        url: https://lukeocodes.dev/websocket-vs-rest-tts-voice-agents
        mainEntityOfPage: https://lukeocodes.dev/websocket-vs-rest-tts-voice-agents
        inLanguage: en
        author:
          - "@id": https://lukeocodes.dev/authors/luke#person
        isPartOf:
          "@id": https://lukeocodes.dev/#website
        keywords: Text-to-Speech, Voice Agents, Streaming, API Design, Latency
        articleSection: Text-to-Speech
        about:
          - "@type": Thing
            name: Text-to-Speech
          - "@type": Thing
            name: Voice Agents
        abstract: Choosing the wrong protocol for your WebSocket TTS integration adds architectural debt that compounds every time you scale. a persistent WebSocket connection can save 50 to 100 milliseconds per request compared to REST in multi-turn conversations.
        speakable:
          "@type": SpeakableSpecification
          cssSelector:
            - .post-tldr
            - h1
        image: https://lukeocodes.dev/og.png?h=WebSocket+vs+REST+TTS+APIs+for+Voice+Agents&d=Choosing+between+WebSocket+and+REST+for+your+streaming+TTS+API+changes+your+voice+agent%27s+latency+floor.+Here+is+how+to+pick+the+right+protocol.&e=Writing
        wordCount: 985
        timeRequired: PT5M
        publisher:
          "@id": https://ably.com/#organization
      - "@type": BreadcrumbList
        itemListElement:
          - "@type": ListItem
            position: 1
            name: Home
            item: https://lukeocodes.dev
          - "@type": ListItem
            position: 2
            name: Writing
            item: https://lukeocodes.dev/blog
          - "@type": ListItem
            position: 3
            name: WebSocket vs REST TTS APIs for Voice Agents
            item: https://lukeocodes.dev/websocket-vs-rest-tts-voice-agents
---

[Luke Oliff.](/)

- [Blog](/blog)
- [CV](/cv)
- [Uses](/uses)
- [User manual](/user-manual)
- [Living with ADHD](/living-and-working-with-adhd)
- [RSS](/rss.xml)

[Luke Oliff · Writing](/blog)

# WebSocket vs REST TTS APIs for Voice Agents

Aug 2026 · [Text-to-Speech](/blog/category/text-to-speech) · 5 min read · [Luke Oliff](/authors/luke)

**TL;DR:** Choosing the wrong protocol for your WebSocket TTS integration adds architectural debt that compounds every time you scale. a persistent WebSocket connection can save 50 to 100 milliseconds per request compared to REST in multi-turn conversations.

![A diagram comparing REST and WebSocket protocols for TTS audio delivery. REST shows a single text block producing one complete audio waveform with a clock indicating delay. WebSocket shows multiple text fragments producing audio chunks that stream continuously to a speaker with minimal delay.](/blog/websocket-vs-rest-tts-voice-agents/hero.png)

Choosing the wrong protocol for your WebSocket TTS integration adds architectural debt that compounds every time you scale. a persistent WebSocket connection can save 50 to 100 milliseconds per request compared to REST in multi-turn conversations. for voice agents running at scale, that latency gap translates directly to interrupted callers and a broken experience.

If your voice agent takes longer than 500 milliseconds to respond, you have already lost the conversation. humans hand off conversational turns in roughly 200 milliseconds. every millisecond spent opening HTTP connections is a millisecond you cannot spend on LLM reasoning.

## How REST and WebSocket handle audio delivery

Protocol choice comes down to one question: can playback start before synthesis finishes?

REST text-to-speech follows a straightforward pattern. you send text, the server synthesizes the entire audio file, and you get the complete response back. the trade-off is clear. you avoid connection state, keep-alives, and reconnection logic. but your user waits for synthesis to complete before hearing anything.

The WebSocket protocol establishes a persistent, bidirectional connection. once that connection is open, your TTS provider sends audio chunks as they are generated. you can start playback while synthesis continues.

HTTP chunked transfer encoding splits the difference. you make a standard HTTP request, but the server sends the response in chunks. you get progressive audio delivery without WebSocket's connection management overhead. Speechify supports this via the `/v1/audio/stream` endpoint, returning raw PCM chunks. I wrote about this approach in [streaming TTS directly to the browser with Web Audio API](/streaming-tts-to-the-browser-with-web-audio-api).

## When REST is the right call for TTS

REST is the right choice when the user can wait for a complete audio asset or when you want simple, stateless failure handling.

If you are pre-generating podcast intros, narrating help articles, or producing audiobook chapters, streaming adds little value. you need the complete file. REST's stateless architecture means simpler retries and easier caching.

For short, infrequent prompts, the overhead of maintaining a persistent WebSocket connection can outweigh the benefit. REST's per-request overhead is negligible at low volume, and operational complexity stays low.

## When WebSocket wins for voice agents

WebSocket TTS earns its complexity when your text source is itself a stream (LLM token output) and when interruption handling changes user experience.

Voice agents need to start speaking before they have finished "thinking." when your LLM generates tokens incrementally and your TTS needs to synthesize incrementally, WebSocket is the cleanest architecture. the production pattern is usually LLM tokens flowing into a buffer, that buffer feeding a streaming TTS API over WebSocket, and audio chunks streaming to the client for immediate playback.

In a multi-turn conversation with ten or more exchanges, connection reuse adds up quickly. REST pays connection overhead on every request. WebSocket pays it once, then reuses the connection. at scale, multiplexing sessions over a persistent WebSocket connection shaves another 50 milliseconds off time-to-first-audio.

Interruption is also normal. your pipeline should treat TTS output as cancellable work, not a fire-and-forget response. this is where WebSocket control messages and session state pay for themselves. if the user barges in, you can send a flush command over the open socket immediately.

## How telephony changes the protocol math

For PSTN voice agents, WebSocket's transport advantage often gets partially absorbed by the rest of the telephony pipeline.

PSTN's 8kHz sampling rate creates a 4kHz audio bandwidth ceiling. any wideband TTS audio gets downsampled before reaching the caller. the practical implication is simple. protocol choice will not rescue a poor telephony audio path. if your agent sounds bad, the fix is usually codec selection and transcoding hygiene, not switching REST to WebSocket. use `ulaw_8000` for telephony endpoints to avoid transcoding hops.

Your TTS output still has to be packetized into fixed-duration RTP frames and smoothed by jitter buffers. if upstream audio arrives in uneven chunks, your jitter buffer can grow to compensate, erasing any protocol-level win.

## Making the decision

You can usually pick the right protocol by checking three things.

First, look at your text source. if it is a stream of LLM tokens, that points to WebSocket. if it is a complete block of CMS content, that points to REST.

Second, look at your playback target. if the user needs audio immediately, interactive playback points to WebSocket or HTTP chunking. async delivery points to REST.

Third, look at your connection state tolerance. if you want to avoid managing reconnect storms during deploys, HTTP chunking gives you progressive playback without the persistent socket overhead.

## Frequently asked questions

### Which protocol has the lowest TTS latency?
WebSocket typically offers the lowest time-to-first-audio for multi-turn conversations because it eliminates connection setup overhead after the first request. multiplexing sessions over a single WebSocket can save an additional 50 milliseconds per turn compared to opening new connections.

### Can I stream TTS audio without WebSockets?
yes. HTTP chunked transfer encoding allows progressive audio delivery over a standard REST-style POST request. the Speechify `/v1/audio/stream` endpoint uses this to stream raw PCM audio chunks back to the client as they generate.

### Why do voice agents need streaming TTS?
voice agents use streaming TTS to start speaking before the LLM has finished generating the complete response. by feeding LLM tokens into a streaming TTS API at sentence boundaries, the agent can begin audio playback while the next sentence is still generating. this keeps latency under the 500-millisecond threshold required for natural conversation.

### What is the best TTS model for voice agents?
Simba 3.2 is the recommended model for English voice agents on the Speechify API. it is optimized for low-latency streaming and sits at the top of independent leaderboards like Artificial Analysis for voice quality and naturalness.

[← Newer: EU AI Act Voice Watermarking: What TTS Builders Must Know](/eu-ai-act-voice-watermarking)

[All posts](/blog) →

## Search this site

`GET https://lukeocodes.dev/search.json?q=<words>` returns matching posts as JSON, each with its page URL and its markdown URL. Add `&limit=<1-50>` for more than 10. How it works: [/blog/search](https://lukeocodes.dev/blog/search.md).

```sh
curl "https://lukeocodes.dev/search.json?q=developer+relations"
```

---

© 2026 Luke Oliff. Posts live at the root of this site.

- [GitHub](https://github.com/lukeocodes)
- [LinkedIn](https://www.linkedin.com/in/lukeocodes)
- [X](https://x.com/lukeocodes)
- [Bluesky](https://bsky.app/profile/lukeocodes.dev)
- [Email](mailto:luke@lukeoliff.com)
- [RSS](/rss.xml)

## Cookies

This site sets one analytics cookie, from Google Analytics, and only in a browser that accepts the cookie banner. A client that does not run scripts sets no cookies, so there is nothing to accept or decline here.

[Cookie policy](/cookies)
