Pipeline wires these components together and
exposes hooks for observing and shaping each turn.
Pipeline
The voice stack an agent runs on: how it hears, thinks, and speaks. Compose a cascade by passing components (stt, llm, tts plus vad and
turn_detector), or a speech-to-speech setup via realtime_config. Also carries
behavior configuration like interruption, end-of-utterance, the context window, DTMF,
and wake-up. Register pipeline-event hooks with the @pipeline.on(...) decorator.
Constructor
Speech-to-text component (cascade mode).
Language model. A realtime/speech-to-speech model enables realtime mode.
Text-to-speech component (cascade mode).
Voice-activity detector (e.g. Silero).
End-of-turn detector deciding when the caller has finished.
Optional visual avatar component.
Optional input noise-cancellation component.
End-of-utterance tuning (
EOUConfig).Barge-in / interruption tuning (
InterruptConfig).Optional structured conversation flow.
Conversation-history budget (
ContextWindow).Optional voicemail detector for outbound calls.
Handler for touch-tone (DTMF) keypad input.
Seconds of caller silence before a wake-up prompt fires.
Maximum wake-up prompts before giving up.
Speech-to-speech configuration (
RealtimeConfig).Enable the streaming
@pipeline.on("llm") hook.Per-chunk timeout for the LLM stream hook. Default 100.
Grace period before treating playback as finished. Default 0.
Regexes whose matching transcript fragments are dropped.
Literal word replacements applied to transcripts.
End the session after this much silence.
change_component
change_pipeline
emit
The event to emit.
get_latest_frames
Number of trailing frames to return. Default 1.
Up to
num_frames most recent frames in chronological order, or an empty list when num_frames is non-positive.get_session_metrics_snapshot
An empty dictionary. Metrics collection is reported through the
PipelineMetricsHooks hooks rather than this snapshot.interrupt
off
The event the handler was registered for.
The handler to remove.
on
@pipeline.on("event")) or by passing
the callback directly.
Name of the pipeline event to subscribe to.
Callback to register. If omitted, a decorator is returned.
The registered callback when
callback is provided, otherwise a decorator that registers the callable it wraps.process_text
The text to process through the session.
push_audio_frame
audio_delta hooks with an incoming audio frame.
The audio frame to dispatch to registered hooks.
push_vision_frame
vision_frame hooks.
The vision frame to append to the buffer and dispatch.
reply_with_context
Instructions steering the generated reply.
send_message
The text for the agent to say.
set_agent
The agent instance to associate with the pipeline.
PipelineHooks
Registry of callbacks bound to pipeline events. Tracks single-slot stream hooks (stt, tts, llm_stream) and
multi-subscriber event hooks. Callbacks are registered through the
on decorator and retrieved by the pipeline at the appropriate
points in the conversation lifecycle.
Constructor
clear_all_hooks
get_hooks
Name of the event to look up.
The list of registered callbacks, or an empty list if none.
has_llm_observation_hooks
True if any non-streaming llm observation hooks exist.
has_llm_stream_hook
True if an LLM stream hook is registered.
has_stt_stream_hook
True if a speech-to-text stream hook is registered.
has_tts_stream_hook
True if a text-to-speech stream hook is registered.
on
Name of the pipeline event to subscribe to.
A decorator that registers the wrapped callable and returns it unchanged.
registered_names
Event names with at least one registered callback, including the single-slot
stt, tts, and llm_stream hooks when set.PipelineHookError
Raised when a requested@pipeline.on(...) hook is not supported.
Constructor
Name of the unsupported hook.
Explanation of why the hook is unsupported.
Optional suggested alternative, appended to the message.
PipelineComponent
Individual components that can participate in the processing pipeline.PipelineConfig
Immutable description of a resolved pipeline configuration.Fields
The high-level operating mode of the pipeline.
The realtime model mode, or
None if not in a realtime mode.Whether the pipeline operates in a realtime mode.
The set of components active in this pipeline.
has_component
The pipeline component to look for.
True if the component is part of the active components.PipelineMode
Operating modes of the processing pipeline, defining which components are active.RealtimeMode
Modes for a realtime model, ranging from full speech-to-speech to hybrid configurations.STT
Abstract base class for speech-to-text providers. Implementations convert audio input into transcription events and may emit an'error' event when a failure occurs.
Constructor
aclose
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_stt_transcript
An async callable that receives each
STTResponse.process_audio
Raw audio bytes to transcribe.
Optional language code to guide recognition.
stream_transcribe
An async iterator yielding raw audio byte chunks.
STTResponse: Transcription events produced as audio is consumed.
STTResponse
Event emitted by a speech-to-text provider.Fields
The type of speech event this response represents.
The transcription payload associated with the event.
Optional provider-specific metadata.
SpeechData
Transcription payload produced by a speech-to-text provider.Fields
The recognized text.
Recognition confidence score in the range 0.0 to 1.0.
Detected or configured language code, if available.
Start time of the recognized segment, in seconds.
End time of the recognized segment, in seconds.
Duration of the recognized segment, in seconds.
LLM
Abstract base class for language model providers. Implementations generate streamed chat responses and may emit an'error' event when a failure occurs.
Constructor
aclose
cancel_current_generation
chat
The conversation history to send to the model.
Optional tool definitions the model may call.
Optional conversational graph guiding the exchange.
LLMResponse: Response chunks produced as the model generates output.
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.LLMResponse
A single response chunk produced by a language model provider.Fields
The text content of the response.
The chat role associated with the content.
Optional provider-specific metadata.
TTS
Abstract base class for text-to-speech providers. Implementations synthesize text into audio output and may emit an'error' event when a failure occurs.
Constructor
Sample rate of the synthesized audio, in Hz.
Number of audio channels in the synthesized output.
aclose
emit
The event to emit.
interrupt
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_first_audio_byte
A callable, optionally async, invoked with synthesis timing information when the first audio byte is emitted.
synthesize
The text to synthesize; coerced to a string if needed.
VAD
Abstract base class for voice activity detection providers. Implementations analyze audio to detect speech and silence boundaries and may emit'error' and 'info' events.
Constructor
Sample rate of the input audio, in Hz.
Speech probability threshold above which audio is treated as speech.
Minimum duration, in seconds, required to confirm a speech segment.
Minimum duration, in seconds, required to confirm a silence segment.
aclose
emit
The event to emit.
flush
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_vad_event
An async callable that receives each
VADResponse.process_audio
Raw audio bytes to analyze.
VADResponse
Event emitted by a voice activity detection provider.Fields
The type of voice activity event this response represents.
The voice activity payload associated with the event.
Optional provider-specific metadata.
VADData
Voice activity detection payload describing the current speech state.Fields
Whether speech is currently detected.
Detection confidence score in the range 0.0 to 1.0.
Time of the detection, in seconds.
Accumulated duration of detected speech, in seconds.
Accumulated duration of detected silence, in seconds.
EOU
Abstract base class for end-of-utterance detection providers. Implementations estimate the likelihood that a speaker has finished their turn and may emit an'error' event when a failure occurs.
Constructor
Probability threshold above which an utterance is considered complete.
aclose
cleanup
detect_end_of_utterance
The conversation context used to evaluate the utterance.
Optional probability threshold overriding the configured one.
True if the end-of-utterance probability meets or exceeds the threshold, otherwise False.emit
The event to emit.
get_eou_probability
0.5 when no result is available or the value cannot be parsed.
The conversation context used to evaluate the utterance.
The end-of-utterance probability in the range 0.0 to 1.0.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.set_threshold
The new probability threshold.
RealtimeBaseModel
Base class for realtime models supporting asynchronous lifecycle management. Provides an asynchronous context manager interface and a no-op cleanup contract that subclasses may override to release resources.Constructor
aclose
returns
None.cleanup
aclose.
returns
None.RealtimeLLMAdapter
The realtime model instance to adapt.
agent
Optional agent the model is associated with. Currently unused.
returns
The same
realtime_model instance, tagged as a realtime model.FallbackSTT
Speech-to-text provider that falls back across an ordered list of providers. The first provider is used as the primary. When a provider fails, the fallback machinery temporarily disables it and routes to the next available provider, optionally disabling it permanently after repeated failures.Constructor
Ordered list of STT providers; the first is the primary.
Duration in seconds a failing provider is temporarily disabled before being retried.
Number of failed attempts after which a provider is permanently disabled.
Interval in seconds between checks for recovery of a disabled provider.
aclose
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_stt_transcript
An async callable that receives each
STTResponse.process_audio
Raw audio bytes to transcribe.
Optional language code to guide recognition.
stream_transcribe
An async iterator yielding raw audio byte chunks.
STTResponse: Transcription events produced as audio is consumed.
FallbackLLM
Language model provider that falls back across an ordered list of providers. The first provider is used as the primary. When a provider fails, the fallback machinery temporarily disables it and routes to the next available provider, optionally disabling it permanently after repeated failures.Constructor
Ordered list of LLM providers; the first is the primary.
Duration in seconds a failing provider is temporarily disabled before being retried.
Number of failed attempts after which a provider is permanently disabled.
Interval in seconds between checks for recovery of a disabled provider.
aclose
cancel_current_generation
chat
The conversation history to send to the model.
Optional tool definitions the model may call.
Optional conversational graph guiding the exchange.
LLMResponse: Response chunks produced as the model generates output.
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.FallbackTTS
Text-to-speech provider that falls back across an ordered list of providers. The first provider is used as the primary. When a provider fails, the fallback machinery temporarily disables it and routes to the next available provider, optionally disabling it permanently after repeated failures.Constructor
Ordered list of TTS providers; the first is the primary.
Duration in seconds a failing provider is temporarily disabled before being retried.
Number of failed attempts after which a provider is permanently disabled.
Interval in seconds between checks for recovery of a disabled provider.
aclose
emit
The event to emit.
interrupt
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_first_audio_byte
A callable, optionally async, invoked with synthesis timing information when the first audio byte is emitted.
synthesize
The text to synthesize; coerced to a string if needed.
UtteranceHandle
Tracks the lifecycle of a single spoken utterance. Provides identity and interruption state for an utterance, lets callers register callbacks for when the final audio byte is emitted, and can be awaited to block until the utterance completes or is interrupted.Constructor
Identifier for the utterance. A random UUID string is generated when not provided.
Whether the utterance may be interrupted without forcing. Defaults to
True.done
True if the utterance has completed or been interrupted, otherwise False.interrupt
force is set, the
utterance is marked as interrupted and completed and any registered
last-audio-byte callbacks are invoked. Otherwise the call is a no-op.
Interrupt even when the utterance is not interruptible. Defaults to
False.on_last_audio_byte
Zero-argument callable invoked when the last audio byte is reached.
The same
callback, allowing use as a decorator.