> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slng.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Pipecat plugin

> The pipecat-slng Python package connects a Pipecat pipeline to any SLNG speech to text or text to speech model by swapping a single model string.

`pipecat-slng` adds speech to text (STT) and text to speech (TTS) services for
[Pipecat](https://github.com/pipecat-ai/pipecat). It routes your pipeline through
the SLNG gateway, so any streaming model on the platform works behind one API
key. Swap the `model` string to switch provider; no other code changes.

This page is the plugin reference. For a walkthrough that sets up your models in
the dashboard and applies the change, see the
[Pipecat integration guide](/guides/integrate/pipecat).

<Note>
  Tested with Pipecat v1.8.0. `world_part` requires `pipecat-slng` 0.6.0 or
  later. Upgrading from an earlier release? See [Move from `base_url`](#move-from-base_url).
</Note>

## Prerequisites

* Python 3.11+ and `pipecat-ai>=1.8.0`
* A [Pipecat](https://github.com/pipecat-ai/pipecat) project
* An SLNG API key. See [Create your API key](/guides/get-started/quickstart#create-your-api-key).

## Install

```bash theme={null}
uv add pipecat-slng
# or: pip install pipecat-slng
```

## Quickstart

Each service reads your key via `api_key` and needs a `world_part`, the region
that handles its requests. Create an STT and a TTS service and add them to your
pipeline:

```python theme={null}
import os

from pipecat_slng import SlngSTTService, SlngTTSService

stt = SlngSTTService(
    api_key=os.getenv("SLNG_API_KEY"),
    world_part="us-east",
    model="slng/deepgram/nova:3-en",
)
tts = SlngTTSService(
    api_key=os.getenv("SLNG_API_KEY"),
    world_part="us-east",
    model="slng/deepgram/aura:2-en",
    voice="aura-2-thalia-en",
)
```

Both services stream over WebSocket, with low latency and mid-utterance
interruption. Common runtime knobs are top-level keyword arguments (`language`,
`speed`, `enable_partials`). For richer overrides, pass
`SlngSTTSettings(...)` or `SlngTTSSettings(...)` to `settings=`.

<Accordion title="Full voice agent example">
  A cascade pipeline (STT → LLM → TTS) using SLNG for speech and OpenAI for the
  language model. The full version, including the Daily transport, lives in
  [`examples/bot.py`](https://github.com/slng-ai/pipecat-slng/blob/main/examples/bot.py).

  ```python bot.py theme={null}
  import os

  from pipecat.audio.vad.silero import SileroVADAnalyzer
  from pipecat.frames.frames import LLMRunFrame
  from pipecat.pipeline.pipeline import Pipeline
  from pipecat.pipeline.runner import PipelineRunner
  from pipecat.pipeline.task import PipelineParams, PipelineTask
  from pipecat.processors.aggregators.llm_context import LLMContext
  from pipecat.processors.aggregators.llm_response_universal import (
      LLMContextAggregatorPair,
      LLMUserAggregatorParams,
  )
  from pipecat.services.openai.responses.llm import OpenAIResponsesLLMService
  from pipecat.transcriptions.language import Language
  from pipecat.transports.base_transport import BaseTransport

  from pipecat_slng import SlngSTTService, SlngTTSService


  async def run_bot(transport: BaseTransport):
      key = os.environ["SLNG_API_KEY"]
      world_part = os.getenv("SLNG_WORLD_PART", "us-east")

      stt = SlngSTTService(
          api_key=key, world_part=world_part, model="slng/deepgram/nova:3-en",
          language=Language.EN, enable_partials=True,
      )
      tts = SlngTTSService(
          api_key=key, world_part=world_part, model="slng/deepgram/aura:2-en",
          voice="aura-2-arcas-en", language=Language.EN,
      )
      llm = OpenAIResponsesLLMService(api_key=os.getenv("OPENAI_API_KEY"))

      context = LLMContext()
      user_agg, assistant_agg = LLMContextAggregatorPair(
          context,
          user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
      )

      pipeline = Pipeline([
          transport.input(), stt, user_agg, llm, tts, transport.output(), assistant_agg,
      ])
      task = PipelineTask(pipeline, params=PipelineParams(enable_metrics=True))

      @task.rtvi.event_handler("on_client_ready")
      async def on_client_ready(rtvi):
          context.add_message({"role": "user", "content": "Please introduce yourself."})
          await task.queue_frames([LLMRunFrame()])

      await PipelineRunner(handle_sigint=False).run(task)
  ```
</Accordion>

## Model identifiers

Models follow `provider/model:variant`, with a `-lang` suffix where the model
exposes per-language variants. Prefix with `slng/` for an SLNG-hosted instance; a
bare identifier is the external passthrough route, required for
[BYOK](#bring-your-own-key-byok).

```python theme={null}
model="slng/deepgram/nova:3-en"      # SLNG-hosted (STT)
model="deepgram/nova:3"              # external passthrough (STT)
```

The full list is the [model catalog](/models/catalog/all-models). Not every model
accepts every option (for example `speed` on TTS); check the
[Unified TTS reference](/api-reference/unified-api/slng/unmute-tts-bridge/unmute-tts-bridge-http) before tuning.

## STT reference

`SlngSTTService` streams speech to text over WebSocket, connecting to
`wss://{region}.api.slng.ai/v1/bridges/unmute/stt/{model}`. Partial transcripts
below `0.5` confidence are dropped before reaching your pipeline. Final
transcripts are always kept. `Language` is imported from
`pipecat.transcriptions.language`.

| Parameter | Default | Description |
| - | - | - |
| `api_key` | required | SLNG API key. |
| `world_part` | required | Region code, as a string or `WorldPart` (see [Region routing](#region-routing)). |
| `model` | `"slng/deepgram/nova:3-en"` | Model identifier. |
| `encoding` | `"linear16"` | `"linear16"`, `"mp3"`, or `"opus"`. |
| `sample_rate` | pipeline rate | Audio sample rate in Hz. |
| `language` | model default | Recognition language. When you omit it, the gateway uses the model's default language. |
| `enable_partials` | `True` | Stream interim transcripts. Only models that support partials use it. |
| `provider_key` | `None` | Your own provider key ([BYOK](#bring-your-own-key-byok), external routes only). |
| `settings` | `None` | `SlngSTTSettings` for runtime updates. |

## TTS reference

`SlngTTSService` streams text to speech over WebSocket, connecting to
`wss://{region}.api.slng.ai/v1/bridges/unmute/tts/{model}`. Changing `voice`, `speed`, or `language` mid-session
reconnects the WebSocket to re-run the init handshake. Pick a voice from the
[text to speech catalog](/models/catalog/text-to-speech).

| Parameter | Default | Description |
| - | - | - |
| `api_key` | required | SLNG API key. |
| `model` | `"slng/deepgram/aura:2-en"` | Model identifier. |
| `world_part` | required | Region code, as a string or `WorldPart` (see [Region routing](#region-routing)). |
| `voice` | `None` | Voice identifier (server default if unset). |
| `encoding` | `"linear16"` | `"linear16"`, `"mp3"`, `"opus"`, `"mulaw"`, or `"alaw"`. |
| `sample_rate` | pipeline rate | Audio sample rate in Hz. |
| `language` | `Language.EN` | Synthesis language. |
| `speed` | `None` | Speech speed multiplier (server default if unset). |
| `provider_key` | `None` | Your own provider key ([BYOK](#bring-your-own-key-byok), external routes only). |
| `pronunciation` | `None` | A [pronunciation dictionary](/guides/execution-layer/tts/pronunciation-dictionaries) for the session, for example `{"mode": "rewrite", "name": "support-pronunciations"}`. |
| `warm_standby_enabled` | `False` | Prepare one spare connection for the next utterance. It opens an extra provider session, which can use connection quota or cost money. |
| `settings` | `None` | `SlngTTSSettings` for runtime updates. |

## Region routing

`world_part` picks the region that handles a service's requests. The service
connects to `{region}.api.slng.ai`, and requests are not routed between
regions. Each service takes its own `world_part`, so STT and TTS can run in
different regions. Pass the region code as a string or as a `WorldPart` value.

This example runs Soniox STT and Fish TTS in Germany:

```python theme={null}
import os

from pipecat.transcriptions.language import Language
from pipecat_slng import SlngSTTService, SlngTTSService, WorldPart

stt = SlngSTTService(
    api_key=os.getenv("SLNG_API_KEY"),
    world_part=WorldPart.EU_WEST,  # same as "eu-west"
    model="soniox/speech-ai:rt-v5",
    language=Language.EN,
)
tts = SlngTTSService(
    api_key=os.getenv("SLNG_API_KEY"),
    world_part="eu-west",
    model="slng/fish/tts:s2.1-pro",
    voice="1258154bb41540c7b9dc0d10cd6704bf",
    language=Language.EN,
)
```

Models differ by region. See [Regions and base URLs](/guides/regions/regions-map#regions-and-base-urls)
for every region code and [models by region](/models/catalog/by-region) for the
speech models each region serves.

### Move from `base_url`

Releases before 0.6.0 picked the region with `base_url`. Remove `base_url` and
pass `world_part` instead. `base_url` still works if its host matches
`world_part`, but it logs a `DeprecationWarning`:

```python theme={null}
# Works, with a warning. Remove base_url.
SlngSTTService(api_key=key, world_part="in", base_url="in.api.slng.ai")

# ValueError: the global api.slng.ai gateway is no longer supported.
SlngSTTService(api_key=key, world_part="in", base_url="api.slng.ai")

# ValueError: the host does not match world_part.
SlngSTTService(api_key=key, world_part="us-west", base_url="in.api.slng.ai")
```

0.6.0 also removes these:

* `region_override` and `world_part_override`. Use `world_part`.
* `enable_vad` on `SlngSTTService`. The service no longer sends it, and it
  never changed transcription. Delete the argument.
* `SlngHttpTTSService`. Use the streaming `SlngTTSService`.

STT no longer sends `language="en"` by default. Pass `language=Language.EN` if
you relied on that default on a multilingual model.

## Bring your own key (BYOK)

Pass `provider_key` to bill an upstream provider directly on your own contract;
both services forward it as the `X-Slng-Provider-Key` header, and the SLNG
cache still applies on top. See [Bring your own key](/guides/models/bring-your-own-key).

```python theme={null}
stt = SlngSTTService(
    api_key=os.getenv("SLNG_API_KEY"),
    world_part="us-east",
    model="deepgram/nova:3",            # external route, no slng/ prefix
    provider_key=os.getenv("SLNG_PROVIDER_KEY"),
)
```

<Note>
  BYOK works on external routes only (no `slng/` prefix). SLNG-hosted routes
  reject the header with an HTTP 400. Since 0.4.0, WebSocket connect-rejection
  errors include the server's response body, so a misrouted request reports the
  reason.
</Note>

## Next steps

* [Pipecat integration guide](/guides/integrate/pipecat) for the migration
  walkthrough.
* The [model catalog](/models/catalog/all-models) and
  [Unified API guide](/guides/models/unified-api).
* Using LiveKit instead? See the [LiveKit plugin](/integrations/plugins/livekit).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.