Skip to main content
Keep your LiveKit agent where it runs and swap its speech to text and text to speech for SLNG-hosted models. You can also route the language model through the SLNG Context Router. The rest of your pipeline stays as it is. There are two ways to make the change. Copy the prompt the dashboard builds for your coding agent, or make the edits yourself.

Prerequisites

  • A running LiveKit agent in Python 3.10+ on livekit-agents>=1.8.8.
  • A project created under Improve my agent > LiveKit, and an API key from its Project Vault. Set up a project for your own code walks through it, including which of the four configurations to pick.
  • The project’s region code, such as eu-north. The key works in that region only.
Starting fresh, or want a known-good reference? The LiveKit templates are complete agents for each LLM option below, with a smoke.py that runs one spoken turn without a microphone.

Choose your LLM option

Speech runs the same way in every option. Only the language model changes:

Use a coding agent

The project builds a migration prompt from your Listen, Think, and Speak choices.
1

Copy the prompt

Click Integrate in the top right, then Copy prompt in the modal. Hand it to your coding agent, which installs the livekit-migration skill and applies the change.
The Integrate button in the top right of the project

Click Integrate in the top right.

The Integrate modal with a Copy prompt button

Copy the prompt.

Your model IDs, voice, language, and region come from what you picked.

Edit the code yourself

The removed lines below depend on your current providers, so match them to your code. For every constructor parameter, see the LiveKit plugin reference.
1

Install the plugins

Use your project’s package manager.
2

Set the environment

Set the project key and region, and a stable agent ID. OPENAI_API_KEY is for the Your LLM and inline BYOK options.
.env
3

Point STT and TTS at SLNG

Swap the two constructors that feed your session. slng_base_url pins the region, and the two external_* IDs tie each call’s speech usage to your agent and call.
The parameter is slng_base_url, not base_url. The plugins pass an unknown keyword on as a model option, so base_url= leaves the plugin on the default api.slng.ai host without an error.
After you build the session, call stt.attach_to_session(session). It lets the STT finalize the caller’s turn as soon as LiveKit detects its end.
4

Set up the LLM

Pick the tab for your option. Both router options send the agent and session IDs as headers, and this call’s template variables in the body. The next step builds variables.
Keep LiveKit’s OpenAI plugin on your own key. The LLM step skips the Context Router.
5

Fill per-call values with template variables

Write values that change per call, such as the caller’s name, as {{name}} placeholders in the prompt. Send their values in the request body as template_variables, and the router fills them in before the model sees the prompt. The cached answer keeps the placeholders, so callers with different names can share it. Building the string yourself puts each caller’s name into the prompt, so no answer can be shared.
  • Send values that are spoken or echoed: names, a company, an appointment time.
  • Keep steering values in the prompt itself. A value that changes what the answer says, such as the reply language, is not a template variable.
  • Give every placeholder a value. A {{name}} with no value returns 422 missing_template_variables.
  • Only the router fills them. With the Your LLM option, write the values into the prompt yourself.
For the syntax, limits, and more examples, see Per-call values.
6

Build it once per call

Build the STT, LLM, and TTS inside the entrypoint, so each call gets its own session ID and template variables. A module-level ID would reuse one session across every call.
agent.py
7

Verify

Run one spoken turn and confirm it completes speech to text, the LLM, and text to speech. With the templates, uv run python smoke.py speech_router runs one turn with no room, and uv run python speech_router.py console talks to your microphone.

Next steps