Skip to main content
pipecat-slng adds STT and TTS services for Pipecat. It routes your pipeline through the SLNG gateway, so you can use any STT or TTS model on SLNG — Deepgram, ElevenLabs, Rime, Sarvam, and more — behind one API key. Swap the model string to switch provider; no other code changes needed.
Tested with Pipecat v1.3.0. BYOK requires pipecat-slng 0.4.0 or later.

Prerequisites

  • Python 3.11+
  • pipecat-ai>=1.3.0
  • A Pipecat project
  • An SLNG API key (get one at app.slng.ai)

Installation

Credentials

You need an SLNG API key. Read it from the SLNG_API_KEY environment variable:
Then pass it to each service via api_key:

Quickstart

Create an STT and TTS service, then add them to your Pipecat pipeline:
SlngSTTService and SlngTTSService stream over WebSocket: low latency, with mid-utterance interruption support. Common runtime knobs are top-level keyword arguments (language, speed, enable_vad, enable_partials). For richer overrides, pass a SlngSTTSettings(...) or SlngTTSSettings(...) to settings=.

Region routing

Both services support gateway region routing. Pin requests to a specific datacenter with region_override, or constrain them to a broad geographic zone with world_part_override. When both are set, region_override wins.
The WebSocket services send these as the X-Region-Override and X-World-Part-Override headers; the HTTP service (below) sends them as the region and world-part query parameters. See the full region list and override behavior at docs.slng.ai/region-override.

Bring your own key (BYOK)

If you already have a contract with an upstream provider, pass your own provider key via provider_key. All three services forward it as the X-Slng-Provider-Key header — on the WebSocket upgrade for the streaming services, on each request for SlngHttpTTSService — so the provider bills your account directly and no SLNG audio-minute fees apply, while the SLNG cache still applies on top. See Bring your own key for caching behavior and the supported provider list.
BYOK only works on external catalog routes — model strings without the slng/ prefix, such as deepgram/nova:3 or deepgram/aura:2. SLNG-hosted slng/... routes reject the header with an HTTP 400 (“BYOK is only supported for external STT/TTS routes”).
If the upstream provider rejects your key, the failure surfaces as a backend_connection_failed error frame over WebSocket, or as the upstream 401/403 with the X-Slng-Auth-Source: client_key response header over HTTP. Since pipecat-slng 0.4.0, WebSocket connect-rejection errors include the server’s response body, so a misrouted BYOK request reports the reason rather than a bare HTTP 400.

Full voice agent example

A complete cascade pipeline — Speech-to-Text → LLM → Text-to-Speech — using SLNG for STT and TTS and OpenAI for the LLM. The bot introduces itself when a client connects:
The full example, including the Daily transport branch, lives in examples/bot.py. Run it with:
Then open http://localhost:7860/client and start talking. It uses the SmallWebRTC transport by default; pass -t daily to use Daily instead (requires pipecat-ai[daily]). Setting SLNG_PROVIDER_KEY (your own Deepgram key) in .env flips the example into BYOK mode on the external deepgram/nova:3 / deepgram/aura:2 routes.

Model identifiers

Models follow the format provider/model:variant. Prefix with slng/ to target an SLNG-hosted instance, and suffix the language where the model exposes per-language variants:
Model strings without the slng/ prefix are external routes, proxied to the provider’s own API:
External routes are required for BYOK. The plugin routes through the SLNG Unmute bridge, so the full list of models you can pass to model= is the bridge’s supported-models list — see Supported models. Not every model accepts every option (for example speed on TTS); check the parameter coverage table before tuning.

STT reference

SlngSTTService streams speech-to-text over WebSocket, connecting to wss://api.slng.ai/v1/bridges/unmute/stt/{model}.

Constructor

Language is imported from pipecat.transcriptions.language.

Confidence filter

When the provider surfaces a confidence score, transcripts below 0.5 are dropped before reaching your pipeline.

Default endpoint

The plugin connects to:

TTS reference (streaming)

SlngTTSService streams text-to-speech over WebSocket, connecting to wss://api.slng.ai/v1/bridges/unmute/tts/{model}. This is the recommended path for interactive voice agents.

Constructor

Runtime settings updates

Changing voice, speed, or language mid-session (via Pipecat settings updates) reconnects the WebSocket to re-run the init handshake. Expect a brief reconnect, not a silent no-op.

Default endpoint

The plugin connects to:

Voice selection

Pick a voice that matches your chosen model. See the Voices pages for what’s available per provider.

HTTP TTS (non-streaming fallback)

For simple request/response synthesis where streaming is not required, use SlngHttpTTSService. It issues one HTTP POST per utterance and returns the full audio body in a single frame.
The HTTP bridge body accepts only {text, voice} — there is no config object. Encoding, sample_rate, language, and speed are therefore not configurable over HTTP; the server returns its default audio format. language and speed are kept for API parity with the WebSocket service but are not sent over the wire.
The service auto-detects WAV (decoded to raw PCM at the file’s sample rate) and plain PCM (passed through at the pipeline’s sample rate). Compressed responses (MP3/Ogg) yield an ErrorFrame — use the streaming SlngTTSService if you need codec control. Pass aiohttp_session= to reuse a shared aiohttp.ClientSession; otherwise one is created internally. Region routing on the HTTP service uses the region and world-part query parameters instead of headers. BYOK works here too: pass provider_key and it is sent as the X-Slng-Provider-Key header on each request (external routes only).

Good to know

Both WebSocket services output linear16 PCM by default and authenticate with api_key. The package exports SlngSTTService, SlngTTSService, and SlngHttpTTSService, plus the SlngSTTSettings and SlngTTSSettings settings classes.
Prefer the streaming SlngTTSService for conversational agents — it supports mid-utterance interruption. Reserve SlngHttpTTSService for batch or non-interactive synthesis.

Next steps