> ## 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

> Add SLNG hosted speech to text and text to speech, and the SLNG Context Router, to a Pipecat pipeline.

Keep your Pipecat bot where it runs and route its speech to text and text to
speech through SLNG. You can also point the language model at the SLNG LLM
Router. Your transport, VAD, turn-taking, prompts, tools, and pipeline order
stay as they are.

The SLNG Pipecat services stream STT and TTS over WebSocket. Use them for
interactive agents that need low latency and mid-utterance interruption.

There are two ways to do it. Set up the layers in the dashboard and copy the
migration prompt for your coding agent, or make the edits yourself.

## Prerequisites

* A running [Pipecat](https://docs.pipecat.ai/) bot with Python 3.11 or later.
* `pipecat-ai>=1.3.0` in your project.
* An SLNG API key. See [Create your API key](/guides/get-started/quickstart#create-your-api-key).
* A BYOK LLM key registered in your org, so the router has a model to route to. See [Bring your own key](/guides/models/bring-your-own-key).
* For the assisted path, a coding agent that supports skills.

The [`pipecat-slng` package](https://pypi.org/project/pipecat-slng/0.4.0/) is
tested with Pipecat v1.3.0.

## Set up your API key

Set `SLNG_API_KEY` in your environment. The examples below read it without
putting the key in your source code.

```bash theme={null}
export SLNG_API_KEY="your-slng-api-key"
```

## Set up in the dashboard

Improving an agent is à la carte. Turn on speech to text, the language model,
text to speech, or any mix of the three. Choose the models, voice, language,
and routing region you want. The dashboard builds a migration prompt from your
choices.

<Steps>
  <Step title="Choose Pipecat">
    Open the **Improve my agent** flow and choose **Pipecat**. The flow keeps
    your existing bot in your own codebase and generates the changes for the
    layers you select.

    <Frame caption="Choose Pipecat in the Improve my agent flow.">
      <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/pipecat-select.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=1e725b8208275b079727fe623cfa4f57" alt="Improve my agent flow with Pipecat highlighted" width="2560" height="1600" data-path="heroshots/pipecat-select.png" />
    </Frame>
  </Step>

  <Step title="Set up Listen">
    Turn on speech to text and choose the model and language. Leave it off to
    keep your current speech to text service.

    <Frame caption="Turn on Listen and pick a speech to text model.">
      <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/livekit-listen.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=f8167c298c81791a645ad7c59b24b9d1" alt="Listen section with the Include STT toggle on" width="2560" height="1600" data-path="heroshots/livekit-listen.png" />
    </Frame>
  </Step>

  <Step title="Set up Think">
    Turn on the language model and choose the model. The Context Router option is
    available in your selected region.

    <Frame caption="Think turned on with a language model selected.">
      <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/livekit-think.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=05db49582f832b19bf5f3c9f2956750c" alt="Think section with the language model turned on and a model chosen" width="2560" height="1600" data-path="heroshots/livekit-think.png" />
    </Frame>
  </Step>

  <Step title="Set up Speak">
    Turn on text to speech and choose the model and voice. Leave it off to keep
    your current text to speech service.

    <Frame caption="Use the Include TTS toggle to turn text to speech on or off.">
      <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/livekit-speak.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=8ca366f30fd71516baf012f884c9432a" alt="Speak section with the Include TTS toggle highlighted" width="2560" height="1600" data-path="heroshots/livekit-speak.png" />
    </Frame>
  </Step>

  <Step title="Copy the prompt">
    Click **Integrate** in the top right, then **Copy prompt** in the modal. The
    dashboard generates a prompt for the platform and layers you selected. Hand
    it to your coding agent. It installs the
    [`pipecat-migration` skill](/guides/integrate/skills) and applies the
    changes to your bot.

    <Columns cols={2}>
      <Frame caption="Click Integrate in the top right.">
        <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/livekit-integrate.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=38d4eebb62662fecd739dd9f668a9a15" alt="The Integrate button in the top right of the project" width="2560" height="1600" data-path="heroshots/livekit-integrate.png" />
      </Frame>

      <Frame caption="Copy the generated prompt.">
        <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/livekit-integrate-prompt.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=9d41a0d84735492232d483c987f6064e" alt="The shared Integrate modal with a Copy prompt button" width="2560" height="1600" data-path="heroshots/livekit-integrate-prompt.png" />
      </Frame>
    </Columns>

    The screenshots show the shared dashboard controls. The prompt content is
    generated for the platform you selected.

    <Accordion title="Example prompt">
      Your model IDs, voice, language, and routing region come from what you
      picked.

      ````md theme={null}
      # Migrate this Pipecat bot to SLNG hosted STT/TTS and the SLNG Context Router

      Use the SLNG `pipecat-migration` skill to replace speech to text and text
      to speech with `SlngSTTService` and `SlngTTSService` from `pipecat-slng`.
      Replace the LLM with Pipecat's `OpenAILLMService` pointed at the SLNG LLM
      Router using `bedrock-mantle/nvidia.nemotron-nano-3-30b:latest`.

      ## Install the skill
      ```bash
      npx skills add slng-ai/skills pipecat-migration
      ```

      ## Selected stack
      - STT: `slng/deepgram/nova:3-en`
      - TTS: `slng/deepgram/aura:2-en`
      - Voice: `aura-2-thalia-en`
      - Language: English (`en`)
      - Region: Europe, via the `eu.api.slng.ai` base URL
      - LLM: SLNG Context Router, model `bedrock-mantle/nvidia.nemotron-nano-3-30b:latest` at `https://au.context-router.slng.ai/v1`

      ## Instructions for the coding agent
      1. Discover the entrypoint, package manager, environment loading, and
         current STT, TTS, and LLM wiring before editing. Do not assume file
         names.
      2. Establish a rollback point with a clean git tree.
      3. Validate `SLNG_API_KEY` without printing it.
      4. Install `pipecat-slng` and import-probe
         `from pipecat_slng import SlngSTTService, SlngTTSService`.
      5. Replace only the STT and TTS constructors that feed `Pipeline([...])`.
         Keep the transport, VAD, context aggregators, and pipeline order
         intact.
      6. Point `OpenAILLMService` at the SLNG Context Router endpoint.
      7. Never inline API keys. Use stable agent and session identifiers in
         request headers, then verify one spoken turn from STT through the LLM
         to TTS.
      ````
    </Accordion>
  </Step>
</Steps>

## Choose a model route

Model IDs use the `provider/model:variant` format. Prefix a model with `slng/`
to use an SLNG-hosted model. A model without the prefix is an external route
proxied through SLNG. See [which models are available](/guides/models/which-models-are-available)
for the model catalog.

```python theme={null}
model="slng/deepgram/nova:3-en"  # SLNG-hosted Deepgram Nova 3
model="deepgram/nova:3"          # External Deepgram route
```

If you use your own provider account, pass its key as `provider_key` and use an
external route without the `slng/` prefix. Do not combine `provider_key` with
an SLNG-hosted model.

## Route requests by region

Pass a regional gateway host as `base_url` to pin requests to a sovereign hub,
for example `eu.api.slng.ai` or `us.api.slng.ai`. The examples use
`eu.api.slng.ai` for Europe. See [using regions in
services](/guides/regions/using-regions-in-services) for more about regional
routing.

## Edit the code yourself

If you would rather not use a coding agent, make the same edits directly. The
removed lines below depend on your current providers, so match them to your
code.

<Steps>
  <Step title="Install the plugin">
    Use your project's package manager.

    ```bash theme={null}
    uv add pipecat-slng
    ```
  </Step>

  <Step title="Point STT and TTS at SLNG">
    Import the SLNG services and swap only the two constructors that feed
    `Pipeline([...])`. Pass the API key through the environment, never as a
    literal.

    ```diff theme={null}
    + import os
    - from pipecat.services.deepgram.stt import DeepgramSTTService
    - from pipecat.services.cartesia.tts import CartesiaTTSService
    + from pipecat_slng import SlngSTTService, SlngTTSService

    - stt = DeepgramSTTService(
    -     api_key=os.environ["DEEPGRAM_API_KEY"],
    -     settings=DeepgramSTTService.Settings(model="nova-3"),
    - )
    - tts = CartesiaTTSService(
    -     api_key=os.environ["CARTESIA_API_KEY"],
    -     settings=CartesiaTTSService.Settings(voice="<your voice>"),
    - )
    + stt = SlngSTTService(
    +     api_key=os.environ["SLNG_API_KEY"],
    +     model="slng/deepgram/nova:3-en",
    +     language="en",
    +     enable_vad=True,
    +     enable_partials=True,
    +     base_url="eu.api.slng.ai",
    + )
    + tts = SlngTTSService(
    +     api_key=os.environ["SLNG_API_KEY"],
    +     model="slng/deepgram/aura:2-en",
    +     voice="aura-2-thalia-en",
    +     language="en",
    +     speed=1,
    +     base_url="eu.api.slng.ai",
    + )
    ```

    Keep the model, voice, language, and routing region you selected in the
    dashboard. `base_url="eu.api.slng.ai"` is an example for the Europe region.
    Use the regional host when your dashboard prompt gives you a different value.
  </Step>

  <Step title="Point the LLM at the SLNG Context Router">
    Use [Pipecat's OpenAI-compatible service](https://docs.pipecat.ai/api-reference/server/services/llm/openai)
    against the router. Pass stable agent and session identifiers in the
    headers, not random values per request.

    ```python theme={null}
    from pipecat.services.openai import OpenAILLMService

    llm = OpenAILLMService(
        api_key=os.environ["SLNG_API_KEY"],
        base_url="https://au.context-router.slng.ai/v1",  # swap au for your region
        settings=OpenAILLMService.Settings(
            model="bedrock-mantle/nvidia.nemotron-nano-3-30b:latest",
        ),
        default_headers={
            "X-Slng-Agent-Id": agent_id,
            "X-Slng-Session-Id": session_id,
        },
    )
    ```

    <Note>
      `pipecat-slng` provides STT and TTS services. The router uses Pipecat's
      `OpenAILLMService`.
    </Note>
  </Step>

  <Step title="Verify">
    Run one spoken turn through your bot's transport and confirm that the
    pipeline completes speech to text, the LLM, and text to speech. Keep the
    existing pipeline order:

    ```python theme={null}
    pipeline = Pipeline([
        transport.input(),
        stt,
        context_aggregator.user(),
        llm,
        tts,
        transport.output(),
        context_aggregator.assistant(),
    ])
    ```
  </Step>
</Steps>

## Next steps

* [Which models are available](/guides/models/which-models-are-available) for
  other speech models and voices you can route through SLNG.
