Skip to content

SPEV: turn decisions up to 36% sooner. Details →

LiveKit

Transcribe user audio or hold a live conversation in a LiveKit Agents session with Sprag models.

Overview

LiveKit Agents runs on Sprag models through LiveKit's own OpenAI plugin, so there is no Sprag-specific plugin to install. Set the Sprag base URL on the plugin and name a Sprag model.

Installation

Install LiveKit Agents with the OpenAI extra:

uv add "livekit-agents[openai]"

Then set your Sprag API key as an environment variable:

export SPRAG_API_KEY=<your_sprag_api_key>

You can generate a key from API keys in the Sprag app, or start with the quickstart if you do not have an account yet.

Connection

Pass the Sprag base URL and your API key when you construct the service.

ArgumentValue
base_urlhttps://api.sprag.ai/v1
api_keyYour Sprag API key

One base URL covers both REST and realtime.

Services

Speech to text. Transcribe user audio with openai.STT over REST or a realtime websocket.

Text to speech. Speak replies with openai.TTS over REST, or stream them from a realtime speech session.

Realtime LLM. openai.realtime.RealtimeModel replaces separate STT, LLM, and TTS stages with one WebSocket.

Choosing between them

Use speech to text for transcription only, feeding your own LLM and TTS, and text to speech to voice the replies of an LLM you already run. Use realtime LLM when the agent should listen and speak in one hop, with no separate STT or TTS call.

If you are not building on LiveKit at all, the realtime API gives you the same one-hop session directly.