Install
Add theslng extra beside your framework extra:
livekit-plugins-slng for LiveKit and pipecat-slng for Pipecat. The installation page lists every extra.
Speech only
Use SLNG speech to text and text to speech with any LLM. This example uses Soniox to hear the caller and Fish Audio to speak.tracking_ids(state.call)gives both plugins the agent’s id and the call’s session id. SLNG groups usage by them. Build the call state first, so the ids exist.- Put both services in the session or the pipeline. On LiveKit, also call
stt.attach_to_session(session)after you build the session. SLNG_WORLD_PARTmust be your SLNG project’s region. A key used in another region gets 401 from the router.
Use the Context Router
RouterModelCall sends each model request to the SLNG Context Router. Give it to your framework through a small adapter.
- The adapter sends the prompt with its
{{placeholders}}still in it, and the values fromstatebeside it. The router fills the prompt, so the model sees the same text it would see on a native LLM. - The router retries and fails over by its own rules.
confignames the models and your keys: see the next section. - OpenAI refuses function tools with reasoning on, so an agent with tools sends
reasoning_effort"none". An agent with no tools may leave it out.
UnmuteAgent, give the router to the agent’s spec instead: AgentSpec(PROMPT, model=router). Build the router per call, after the state, because it reads state.call. Arguments you leave out are read from the SLNG_* settings.
Bring your own model key
Send your own router config with every request. It names the model the router uses and holds your own provider key.RouterConfig.singleputs one model on your OpenAI key.RouterModelCall(config=config)sends it with every request.- Always pass a config. Without one, the router uses a stored config that may not select your model, and answers 400.
- Only an SLNG key from a project on the Execution Layer may send a config. Any other key gets 403
project_mode_forbidden.
Without the router
OpenAIModelCall is a native call for any OpenAI-compatible endpoint. It sends nothing to SLNG, and the library fills the prompt. See Use any OpenAI-compatible model.
The complete files with speech and the router together are examples/parcel-desk/livekit/agent.py and examples/parcel-desk/pipecat/bot.py.
Where to go next
SLNG reference
Every RouterModelCall argument, header, config field, error and Gemini detail.
The model call
The interface the router implements, and FallbackModelCall.
Settings
The
SLNG_* variables and how to check them at startup.Context Router on Unmute
The
agent.yaml side of the router.