Skip to content

Pipecat: realtime LLM

Hold a live voice conversation through Pipecat's realtime LLM service.

OpenAIRealtimeLLMService replaces the transcribe / process / synthesize stages with a single WebSocket to a model that listens and speaks.

Setup

import os

from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService

llm = OpenAIRealtimeLLMService(
    api_key=os.environ["SPRAG_API_KEY"],
    base_url="wss://api.sprag.ai/v1/realtime",
    settings=OpenAIRealtimeLLMService.Settings(
        model="symphony",
        system_instruction="Be concise and stay on topic.",
    ),
)

The service builds its own connect URL from settings.model, so base_url takes no query string.

Add it to a pipeline as transcribe, process, and synthesize combined, with no separate STT or TTS stage:

pipeline = Pipeline([
    transport.input(),
    context_aggregator.user(),
    llm,
    transport.output(),
])

Instructions

system_instruction maps onto the realtime session's instructions field: persona, behavior, task guidance. See session configuration.

Turn timing

Turn detection follows the same turn_detection settings the raw protocol takes.

Reference