Skip to main content

Pipeline

Create a Pipeline from the given component PipelineOptions.

Constructor

stt
any
Speech-to-text provider. Defaults to null.
llm
any
Language-model provider. Defaults to null.
tts
any
Text-to-speech provider. Defaults to null.
vad
any
Voice-activity-detection provider. Defaults to null.
turnDetector
any
End-of-turn detector. Defaults to null.
avatar
any
Avatar/video provider. Defaults to null.
denoise
any
Audio denoiser. Defaults to null.
eouConfig
EOUConfig | null
End-of-utterance config. Defaults to EOUConfig().
interruptConfig
InterruptConfig | null
Interruption-handling config. Defaults to InterruptConfig().
conversationalGraph
any
Conversational-graph routing config. Defaults to null.
contextWindow
ContextWindow | any
Context-window trimming policy. Defaults to null.
voiceMailDetector
any
Voicemail detector. Defaults to null.
dtmfHandler
any
DTMF (touch-tone) handler. Defaults to null.
realtimeConfig
RealtimeConfig | null
Realtime speech-to-speech config. Defaults to null.
llmStreamHookEnabled
boolean
Enable the streaming LLM token-rewrite hook. Defaults to false.
llmStreamHookTimeoutMs
number
Per-token timeout for the LLM stream hook, in milliseconds. Defaults to 100.
playbackGraceMs
number
Grace period in milliseconds before considering playback finished. Defaults to 0.
sttFilterPatterns
string[] | null
Regex patterns to drop from transcripts. Defaults to DEFAULT_STT_FILTER_PATTERNS.
sttWordSubstitutions
Record<string, string> | null
Word replacements applied to transcripts ({ from: to }). Defaults to {}.
inactivityTimeoutSeconds
number | null
Seconds of inactivity before the session times out, or null to disable. Defaults to null.
wakeUp
number | null
Seconds of caller silence before the agent’s onWakeUp hook fires, or null to disable. Defaults to null.
wakeUpMaxAttempts
number | null
Maximum wake-up nudges before the call ends, or null for no cap. Defaults to null.
filterFillerWords
boolean
Drop a transcript that consists solely of a filler word (“okay”, “yeah”, …) without an LLM turn. Defaults to false (every transcript reaches the model).
fillerWords
string[] | null
Filler words used when PipelineOptions.filterFillerWords is on. When unset, the runtime supplies its own defaults.

changeComponent

Hot-swap components that already exist in the pipeline, in place. Invalid swaps warn and are skipped; passContext: false clears the LLM’s history (only after the runtime confirms the swap succeeded).
opts
ChangeComponentOptions

changePipeline

Replace the whole pipeline mid-session (live mode switch): pass the complete target pipeline; the mode is inferred from the llm/components you pass.
opts
ChangePipelineOptions

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getLatestFrames

Return the most recent captured vision frames.
numFrames
Number of frames to return (most recent). Defaults to 1.
returns
any[]

getSessionMetricsSnapshot

Snapshot of session metrics (empty in this SDK build).
returns
Record<string, any>

interrupt

Interrupt the bound agent’s current turn.

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

Register a hook for event. Usable directly (on(event, fn)) or as a decorator factory (on(event)). Delegates to Pipeline.hooks.
event
string
required
callback
PipelineHookFn
returns
any

once

event
string
required
handler
EventHandler
required
returns
EventHandler

processText

Feed text into the bound agent’s session as model input.
text
string
required

pushAudioFrame

Fire audio_delta hooks for an incoming audio frame.
frame
any
required

pushVisionFrame

Buffer a vision frame (capped at VISION_FRAME_BUFFER_MAX) and fire vision_frame hooks.
frame
any
required

removeAllListeners

event
string

replyWithContext

Generate a reply to instructions on the bound agent’s session.
instructions
string
required
extras
Record<string, any>

sendMessage

Speak text on the bound agent’s session.
text
string
required
extras
Record<string, any>

setAgent

Bind the agent that runs on this pipeline.
agent
any
required

PipelineHooks

Registry of pipeline hooks. Accessed via Pipeline.hooks or Pipeline.on(...); lets you observe or transform audio, transcripts, LLM tokens, and lifecycle events.

Constructor

clearAllHooks

Remove all registered hooks.

getHooks

All multi-handler callbacks registered for event.
event
string
required
returns
PipelineHookFn[]

hasLlmObservationHooks

Whether any observe-only llm hooks are registered.
returns
boolean

hasLlmStreamHook

Whether an LLM stream hook is registered.
returns
boolean

hasSttStreamHook

Whether an STT stream hook is registered.
returns
boolean

hasTtsStreamHook

Whether a TTS stream hook is registered.
returns
boolean

on

event
string
required
fn
PipelineHookFn
returns
PipelineHookFn | ((fn: PipelineHookFn) => PipelineHookFn)

registeredNames

Names of all hooks that currently have at least one handler.
returns
string[]

PipelineHookError

Thrown when a registered pipeline hook is not supported.

Constructor

hookName
string
required
reason
string
required
alternative
string | null
default:"null"

PipelineComponent

A processing component that can be present in a Pipeline.

PipelineConfig

Create a PipelineConfig.

Constructor

pipelineMode
PipelineMode
required
Overall pipeline shape.
realtimeMode
RealtimeMode | null
required
Realtime wiring, or null for a non-realtime pipeline.
isRealtime
boolean
required
Whether a realtime model is in use.
activeComponents
Iterable<PipelineComponent>
required
Components present in the pipeline.

hasComponent

Whether the given component is part of this pipeline.
component
PipelineComponent
required
returns
boolean

PipelineMode

The shape of the configured pipeline, derived from which components (PipelineComponent) are present. Determined automatically from the Pipeline you build; not normally set by hand.

RealtimeMode

How a realtime speech-to-speech model is wired into the pipeline.

STT

Base class for speech-to-text providers. Provider plugins (e.g. DeepgramSTT({...})) extend this; subclass it only to integrate a custom STT.

Constructor

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

Provider configuration sent to the Zero Runtime. Override to supply settings.
returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

onSttTranscript

Register a callback to receive transcripts as they are produced.
callback
SttTranscriptCallback
required

processAudio

Process a buffer of audio frames. Override in a custom provider.

removeAllListeners

event
string

streamTranscribe

Transcribe a streaming audio source, yielding STTResponses. Override in a custom provider.
returns
AsyncIterator<STTResponse>

STTResponse

Create an STTResponse.

Constructor

eventType
SpeechEventType
required
data
SpeechData
required
metadata
Record<string, any> | null

SpeechData

Create SpeechData.

Constructor

text
string
required
confidence
number
language
string | null
startTime
number
endTime
number
duration
number

LLM

Base class for language-model providers. Provider plugins (e.g. GoogleLLM({...})) extend this; subclass it only to integrate a custom LLM.

Constructor

cancelCurrentGeneration

Cancel the in-flight generation for the current session, if any.

chat

Stream a completion for the given messages, yielding LLMResponse chunks.
returns
AsyncIterator<LLMResponse>

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

Provider configuration sent to the Zero Runtime. Override to supply settings.
returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

removeAllListeners

event
string

LLMResponse

Create an LLMResponse.

Constructor

content
string
required
role
ChatRole
required
metadata
Record<string, any> | null

TTS

Base class for text-to-speech providers. Provider plugins (e.g. CartesiaTTS({...})) extend this; subclass it only to integrate a custom TTS.

Constructor

sampleRate
number
Output sample rate in Hz. Defaults to 24000.
numChannels
number
Number of output channels. Defaults to 1.

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

Provider configuration sent to the Zero Runtime. Override to supply settings.
returns
Record<string, any>

interrupt

Stop the current synthesis.

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

onFirstAudioByte

Register a callback fired when the first synthesized audio byte is emitted.
callback
FirstAudioByteCallback
required

removeAllListeners

event
string

synthesize

Synthesize and speak text on the active session.
text
any
required

VAD

Base class for voice-activity-detection providers. Provider plugins extend this; subclass it only to integrate a custom VAD.

Constructor

sampleRate
number
Input sample rate in Hz. Defaults to 16000.
threshold
number
Speech-probability threshold 0-1 above which audio counts as speech. Defaults to 0.5.
minSpeechDuration
number
Minimum speech duration in seconds to register a start-of-speech. Defaults to 0.5.
minSilenceDuration
number
Minimum silence duration in seconds to register an end-of-speech. Defaults to 0.5.

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

flush

Flush any buffered audio.

getRuntimeConfig

Provider configuration (threshold and durations) sent to the Zero Runtime.
returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

onVadEvent

Register a callback to receive VADResponse events.
callback
VadEventCallback
required

processAudio

Process a buffer of audio frames. Override in a custom provider.

removeAllListeners

event
string

VADResponse

Create a VADResponse.

Constructor

eventType
VADEventType
required
data
VADData
required
metadata
Record<string, any> | null

VADData

Create VADData.

Constructor

isSpeech
boolean
required
confidence
number
timestamp
number
speechDuration
number
silenceDuration
number

EOU

Base class for end-of-utterance (turn-detection) providers. Provider plugins extend this; subclass it only to integrate a custom turn detector.

Constructor

threshold
number
End-of-utterance probability threshold 0-1. Defaults to 0.7.

cleanup

Tear down provider state.

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

detectEndOfUtterance

Whether the current EOU probability meets threshold (or the configured one).
chatContext
any
threshold
number
returns
boolean

emit

event
string
required

getEouProbability

Latest end-of-utterance probability 0-1 (defaults to 0.5 when unknown).
returns
number

getRuntimeConfig

Provider configuration (threshold) sent to the Zero Runtime.
returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

removeAllListeners

event
string

setThreshold

Update the end-of-utterance threshold.
threshold
number
required

FallbackSTT

Create an STT provider that tries each provider in order, failing over to the next when one is unavailable.

Constructor

providers
STT[]
required
Providers in priority order; the first is the primary.
temporaryDisableSec
number
Seconds to skip a failing provider before retrying. Defaults to DEFAULT_TEMPORARY_DISABLE_SEC.
permanentDisableAfterAttempts
number
Failed attempts after which a provider is disabled for the session. Defaults to DEFAULT_PERMANENT_DISABLE_AFTER_ATTEMPTS.
recoveryCheckIntervalSec
number
Seconds between health checks of a disabled provider. Defaults to DEFAULT_RECOVERY_CHECK_INTERVAL_SEC.
latencyThresholdMs
number | null
Latency ceiling in ms for the active provider. When exceeded for consecutiveLatencyHits turns in a row, the chain fails over. Omitted/0 = disabled.
consecutiveLatencyHits
number
Consecutive turns over latencyThresholdMs before failing over. Defaults to 3.

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

onSttTranscript

Register a callback to receive transcripts as they are produced.
callback
SttTranscriptCallback
required

processAudio

Process a buffer of audio frames. Override in a custom provider.

removeAllListeners

event
string

streamTranscribe

Transcribe a streaming audio source, yielding STTResponses. Override in a custom provider.
returns
AsyncIterator<STTResponse>

FallbackLLM

Create an LLM provider that tries each provider in order, failing over to the next when one is unavailable. The primary’s temperature and max_output_tokens settings carry through.

Constructor

providers
LLM[]
required
Providers in priority order; the first is the primary.
temporaryDisableSec
number
Seconds to skip a failing provider before retrying. Defaults to DEFAULT_TEMPORARY_DISABLE_SEC.
permanentDisableAfterAttempts
number
Failed attempts after which a provider is disabled for the session. Defaults to DEFAULT_PERMANENT_DISABLE_AFTER_ATTEMPTS.
recoveryCheckIntervalSec
number
Seconds between health checks of a disabled provider. Defaults to DEFAULT_RECOVERY_CHECK_INTERVAL_SEC.
latencyThresholdMs
number | null
Latency ceiling in ms for the active provider. When exceeded for consecutiveLatencyHits turns in a row, the chain fails over. Omitted/0 = disabled.
consecutiveLatencyHits
number
Consecutive turns over latencyThresholdMs before failing over. Defaults to 3.

cancelCurrentGeneration

Cancel the in-flight generation for the current session, if any.

chat

Stream a completion for the given messages, yielding LLMResponse chunks.
returns
AsyncIterator<LLMResponse>

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

removeAllListeners

event
string

FallbackTTS

Create a TTS provider that tries each provider in order, failing over to the next when one is unavailable.

Constructor

providers
TTS[]
required
Providers in priority order; the first is the primary.
temporaryDisableSec
number
Seconds to skip a failing provider before retrying. Defaults to DEFAULT_TEMPORARY_DISABLE_SEC.
permanentDisableAfterAttempts
number
Failed attempts after which a provider is disabled for the session. Defaults to DEFAULT_PERMANENT_DISABLE_AFTER_ATTEMPTS.
recoveryCheckIntervalSec
number
Seconds between health checks of a disabled provider. Defaults to DEFAULT_RECOVERY_CHECK_INTERVAL_SEC.
latencyThresholdMs
number | null
Latency ceiling in ms for the active provider. When exceeded for consecutiveLatencyHits turns in a row, the chain fails over. Omitted/0 = disabled.
consecutiveLatencyHits
number
Consecutive turns over latencyThresholdMs before failing over. Defaults to 3.

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

returns
Record<string, any>

interrupt

Stop the current synthesis.

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

onFirstAudioByte

Register a callback fired when the first synthesized audio byte is emitted.
callback
FirstAudioByteCallback
required

removeAllListeners

event
string

synthesize

Synthesize and speak text on the active session.
text
any
required

UtteranceHandle

See the class-level description for usage.

Constructor

utteranceId
string
Identifier for the utterance. Default: a generated UUID.
interruptible
boolean
Whether the utterance can be interrupted without force. Default: true.

done

Whether the utterance has finished (completed or interrupted).
returns
boolean

interrupt

Interrupt the utterance, marking it done and firing last-audio-byte callbacks. Has no effect on a non-interruptible utterance unless force is true.
opts
{ force?: boolean }

markDone

Mark the utterance as completed normally, firing last-audio-byte callbacks.

onLastAudioByte

Register a callback that fires when the utterance’s final audio byte has played. If the utterance is already done, the callback runs immediately; otherwise it is queued and fires once when the utterance finishes. Returns the same callback you passed in. Errors thrown by the callback are caught and logged, never propagated.
cb
() => any
required
returns
() => any

then

Makes the handle awaitable; resolves when the utterance finishes.
onfulfilled
((value: void) => TResult1 | PromiseLike<TResult1>) | null
onrejected
((reason: any) => TResult2 | PromiseLike<TResult2>) | null
returns
Promise<TResult1 | TResult2>

wait

Returns a promise that resolves when the utterance finishes.