> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Pipeline

> JavaScript API reference for Pipeline.

## Pipeline

Create a Pipeline from the given component PipelineOptions.

### Constructor

```typescript theme={null}
new Pipeline(opts: PipelineOptions)
```

<ParamField path="stt" type="any">
  Speech-to-text provider. Defaults to `null`.
</ParamField>

<ParamField path="llm" type="any">
  Language-model provider. Defaults to `null`.
</ParamField>

<ParamField path="tts" type="any">
  Text-to-speech provider. Defaults to `null`.
</ParamField>

<ParamField path="vad" type="any">
  Voice-activity-detection provider. Defaults to `null`.
</ParamField>

<ParamField path="turnDetector" type="any">
  End-of-turn detector. Defaults to `null`.
</ParamField>

<ParamField path="avatar" type="any">
  Avatar/video provider. Defaults to `null`.
</ParamField>

<ParamField path="denoise" type="any">
  Audio denoiser. Defaults to `null`.
</ParamField>

<ParamField path="eouConfig" type="EOUConfig | null">
  End-of-utterance config. Defaults to `EOUConfig()`.
</ParamField>

<ParamField path="interruptConfig" type="InterruptConfig | null">
  Interruption-handling config. Defaults to `InterruptConfig()`.
</ParamField>

<ParamField path="conversationalGraph" type="any">
  Conversational-graph routing config. Defaults to `null`.
</ParamField>

<ParamField path="contextWindow" type="ContextWindow | any">
  Context-window trimming policy. Defaults to `null`.
</ParamField>

<ParamField path="voiceMailDetector" type="any">
  Voicemail detector. Defaults to `null`.
</ParamField>

<ParamField path="dtmfHandler" type="any">
  DTMF (touch-tone) handler. Defaults to `null`.
</ParamField>

<ParamField path="realtimeConfig" type="RealtimeConfig | null">
  Realtime speech-to-speech config. Defaults to `null`.
</ParamField>

<ParamField path="llmStreamHookEnabled" type="boolean">
  Enable the streaming LLM token-rewrite hook. Defaults to `false`.
</ParamField>

<ParamField path="llmStreamHookTimeoutMs" type="number">
  Per-token timeout for the LLM stream hook, in milliseconds. Defaults to `100`.
</ParamField>

<ParamField path="playbackGraceMs" type="number">
  Grace period in milliseconds before considering playback finished. Defaults to `0`.
</ParamField>

<ParamField path="sttFilterPatterns" type="string[] | null">
  Regex patterns to drop from transcripts. Defaults to DEFAULT\_STT\_FILTER\_PATTERNS.
</ParamField>

<ParamField path="sttWordSubstitutions" type="Record<string, string> | null">
  Word replacements applied to transcripts (`{ from: to }`). Defaults to `{}`.
</ParamField>

<ParamField path="inactivityTimeoutSeconds" type="number | null">
  Seconds of inactivity before the session times out, or `null` to disable. Defaults to `null`.
</ParamField>

<ParamField path="wakeUp" type="number | null">
  Seconds of caller silence before the agent's `onWakeUp` hook fires, or `null` to disable. Defaults to `null`.
</ParamField>

<ParamField path="wakeUpMaxAttempts" type="number | null">
  Maximum wake-up nudges before the call ends, or `null` for no cap. Defaults to `null`.
</ParamField>

<ParamField path="filterFillerWords" type="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).
</ParamField>

<ParamField path="fillerWords" type="string[] | null">
  Filler words used when PipelineOptions.filterFillerWords is on. When unset, the runtime supplies its own defaults.
</ParamField>

### changeComponent

```typescript theme={null}
changeComponent(opts: ChangeComponentOptions = {}): Promise<void>
```

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).

<ParamField path="opts" type="ChangeComponentOptions" />

### changePipeline

```typescript theme={null}
changePipeline(opts: ChangePipelineOptions = {}): Promise<void>
```

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

<ParamField path="opts" type="ChangePipelineOptions" />

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getLatestFrames

```typescript theme={null}
getLatestFrames(numFrames = 1): any[]
```

Return the most recent captured vision frames.

<ParamField path="numFrames">
  Number of frames to return (most recent). Defaults to `1`.
</ParamField>

<ResponseField name="returns" type="any[]" />

### getSessionMetricsSnapshot

```typescript theme={null}
getSessionMetricsSnapshot(): Record<string, any>
```

Snapshot of session metrics (empty in this SDK build).

<ResponseField name="returns" type="Record<string, any>" />

### interrupt

```typescript theme={null}
interrupt(): void
```

Interrupt the bound agent's current turn.

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, callback?: PipelineHookFn): any
```

Register a hook for `event`. Usable directly (`on(event, fn)`) or as a decorator
factory (`on(event)`). Delegates to Pipeline.hooks.

<ParamField path="event" type="string" required />

<ParamField path="callback" type="PipelineHookFn" />

<ResponseField name="returns" type="any" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### processText

```typescript theme={null}
processText(text: string): Promise<void>
```

Feed `text` into the bound agent's session as model input.

<ParamField path="text" type="string" required />

### pushAudioFrame

```typescript theme={null}
pushAudioFrame(frame: any): void
```

Fire `audio_delta` hooks for an incoming audio frame.

<ParamField path="frame" type="any" required />

### pushVisionFrame

```typescript theme={null}
pushVisionFrame(frame: any): void
```

Buffer a vision frame (capped at VISION\_FRAME\_BUFFER\_MAX) and fire `vision_frame` hooks.

<ParamField path="frame" type="any" required />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### replyWithContext

```typescript theme={null}
replyWithContext(instructions: string, extras: Record<string, any> = {}): Promise<void>
```

Generate a reply to `instructions` on the bound agent's session.

<ParamField path="instructions" type="string" required />

<ParamField path="extras" type="Record<string, any>" />

### sendMessage

```typescript theme={null}
sendMessage(text: string, extras: Record<string, any> = {}): Promise<void>
```

Speak `text` on the bound agent's session.

<ParamField path="text" type="string" required />

<ParamField path="extras" type="Record<string, any>" />

### setAgent

```typescript theme={null}
setAgent(agent: any): void
```

Bind the agent that runs on this pipeline.

<ParamField path="agent" type="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

```typescript theme={null}
new PipelineHooks()
```

### clearAllHooks

```typescript theme={null}
clearAllHooks(): void
```

Remove all registered hooks.

### getHooks

```typescript theme={null}
getHooks(event: string): PipelineHookFn[]
```

All multi-handler callbacks registered for `event`.

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="PipelineHookFn[]" />

### hasLlmObservationHooks

```typescript theme={null}
hasLlmObservationHooks(): boolean
```

Whether any observe-only `llm` hooks are registered.

<ResponseField name="returns" type="boolean" />

### hasLlmStreamHook

```typescript theme={null}
hasLlmStreamHook(): boolean
```

Whether an LLM stream hook is registered.

<ResponseField name="returns" type="boolean" />

### hasSttStreamHook

```typescript theme={null}
hasSttStreamHook(): boolean
```

Whether an STT stream hook is registered.

<ResponseField name="returns" type="boolean" />

### hasTtsStreamHook

```typescript theme={null}
hasTtsStreamHook(): boolean
```

Whether a TTS stream hook is registered.

<ResponseField name="returns" type="boolean" />

### on

```typescript theme={null}
on(event: string, fn?: PipelineHookFn): PipelineHookFn | ((fn: PipelineHookFn) => PipelineHookFn)
```

<ParamField path="event" type="string" required />

<ParamField path="fn" type="PipelineHookFn" />

<ResponseField name="returns" type="PipelineHookFn | ((fn: PipelineHookFn) => PipelineHookFn)" />

### registeredNames

```typescript theme={null}
registeredNames(): string[]
```

Names of all hooks that currently have at least one handler.

<ResponseField name="returns" type="string[]" />

***

## PipelineHookError

Thrown when a registered pipeline hook is not supported.

### Constructor

```typescript theme={null}
new PipelineHookError(hookName: string, reason: string, alternative: string | null)
```

<ParamField path="hookName" type="string" required />

<ParamField path="reason" type="string" required />

<ParamField path="alternative" type="string | null" default="null" />

***

## PipelineComponent

A processing component that can be present in a Pipeline.

```typescript theme={null}
enum PipelineComponent {
  STT = 'stt',
  LLM = 'llm',
  TTS = 'tts',
  VAD = 'vad',
  TURN_DETECTOR = 'turn_detector',
  AVATAR = 'avatar',
  DENOISE = 'denoise',
  REALTIME_MODEL = 'realtime_model',
}
```

***

## PipelineConfig

Create a PipelineConfig.

### Constructor

```typescript theme={null}
new PipelineConfig(opts: { /** Overall pipeline shape. */ pipelineMode: PipelineMode; /** Realtime wiring, or `null` for a non-realtime pipeline. */ realtimeMode: RealtimeMode | null; /** Whether a realtime model is in use. */ isRealtime: boolean; /** Components present in the pipeline. */ activeComponents: Iterable<PipelineComponent>; })
```

<ParamField path="pipelineMode" type="PipelineMode" required>
  Overall pipeline shape.
</ParamField>

<ParamField path="realtimeMode" type="RealtimeMode | null" required>
  Realtime wiring, or `null` for a non-realtime pipeline.
</ParamField>

<ParamField path="isRealtime" type="boolean" required>
  Whether a realtime model is in use.
</ParamField>

<ParamField path="activeComponents" type="Iterable<PipelineComponent>" required>
  Components present in the pipeline.
</ParamField>

### hasComponent

```typescript theme={null}
hasComponent(component: PipelineComponent): boolean
```

Whether the given component is part of this pipeline.

<ParamField path="component" type="PipelineComponent" required />

<ResponseField name="returns" type="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.

```typescript theme={null}
enum PipelineMode {
  REALTIME = 'realtime',
  FULL_CASCADING = 'full_cascading',
  LLM_TTS_ONLY = 'llm_tts_only',
  STT_LLM_ONLY = 'stt_llm_only',
  LLM_ONLY = 'llm_only',
  STT_ONLY = 'stt_only',
  TTS_ONLY = 'tts_only',
  STT_TTS_ONLY = 'stt_tts_only',
  HYBRID = 'hybrid',
  PARTIAL_CASCADING = 'partial_cascading',
}
```

***

## RealtimeMode

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

```typescript theme={null}
enum RealtimeMode {
  FULL_S2S = 'full_s2s',
  HYBRID_STT = 'hybrid_stt',
  HYBRID_TTS = 'hybrid_tts',
  LLM_ONLY = 'llm_only',
}
```

***

## STT

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

### Constructor

```typescript theme={null}
new STT()
```

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

Provider configuration sent to the Zero Runtime. Override to supply settings.

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### onSttTranscript

```typescript theme={null}
onSttTranscript(callback: SttTranscriptCallback): void
```

Register a callback to receive transcripts as they are produced.

<ParamField path="callback" type="SttTranscriptCallback" required />

### processAudio

```typescript theme={null}
processAudio(_audioFrames: Uint8Array, _language?: string | null, ..._extra: any[]): Promise<void>
```

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

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### streamTranscribe

```typescript theme={null}
streamTranscribe(_audioStream: AsyncIterable<Uint8Array>, ..._extra: any[]): AsyncIterator<STTResponse>
```

Transcribe a streaming audio source, yielding STTResponses. Override in a custom provider.

<ResponseField name="returns" type="AsyncIterator<STTResponse>" />

***

## STTResponse

Create an STTResponse.

### Constructor

```typescript theme={null}
new STTResponse(init: { eventType: SpeechEventType; data: SpeechData; metadata?: Record<string, any> | null; })
```

<ParamField path="eventType" type="SpeechEventType" required />

<ParamField path="data" type="SpeechData" required />

<ParamField path="metadata" type="Record<string, any> | null" />

***

## SpeechData

Create SpeechData.

### Constructor

```typescript theme={null}
new SpeechData(init: { text: string; confidence?: number; language?: string | null; startTime?: number; endTime?: number; duration?: number; })
```

<ParamField path="text" type="string" required />

<ParamField path="confidence" type="number" />

<ParamField path="language" type="string | null" />

<ParamField path="startTime" type="number" />

<ParamField path="endTime" type="number" />

<ParamField path="duration" type="number" />

***

## LLM

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

### Constructor

```typescript theme={null}
new LLM()
```

### cancelCurrentGeneration

```typescript theme={null}
cancelCurrentGeneration(): Promise<void>
```

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

### chat

```typescript theme={null}
chat(_messages: any, _opts?: LLMChatOptions): AsyncIterator<LLMResponse>
```

Stream a completion for the given messages, yielding LLMResponse chunks.

<ResponseField name="returns" type="AsyncIterator<LLMResponse>" />

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

Provider configuration sent to the Zero Runtime. Override to supply settings.

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

***

## LLMResponse

Create an LLMResponse.

### Constructor

```typescript theme={null}
new LLMResponse(init: { content: string; role: ChatRole; metadata?: Record<string, any> | null; })
```

<ParamField path="content" type="string" required />

<ParamField path="role" type="ChatRole" required />

<ParamField path="metadata" type="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

```typescript theme={null}
new TTS(opts: TTSOptions)
```

<ParamField path="sampleRate" type="number">
  Output sample rate in Hz. Defaults to `24000`.
</ParamField>

<ParamField path="numChannels" type="number">
  Number of output channels. Defaults to `1`.
</ParamField>

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

Provider configuration sent to the Zero Runtime. Override to supply settings.

<ResponseField name="returns" type="Record<string, any>" />

### interrupt

```typescript theme={null}
interrupt(): Promise<void>
```

Stop the current synthesis.

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### onFirstAudioByte

```typescript theme={null}
onFirstAudioByte(callback: FirstAudioByteCallback): void
```

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

<ParamField path="callback" type="FirstAudioByteCallback" required />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### synthesize

```typescript theme={null}
synthesize(text: any, ..._extra: any[]): Promise<void>
```

Synthesize and speak `text` on the active session.

<ParamField path="text" type="any" required />

***

## VAD

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

### Constructor

```typescript theme={null}
new VAD(opts: VADOptions)
```

<ParamField path="sampleRate" type="number">
  Input sample rate in Hz. Defaults to `16000`.
</ParamField>

<ParamField path="threshold" type="number">
  Speech-probability threshold 0-1 above which audio counts as speech. Defaults to `0.5`.
</ParamField>

<ParamField path="minSpeechDuration" type="number">
  Minimum speech duration in seconds to register a start-of-speech. Defaults to `0.5`.
</ParamField>

<ParamField path="minSilenceDuration" type="number">
  Minimum silence duration in seconds to register an end-of-speech. Defaults to `0.5`.
</ParamField>

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### flush

```typescript theme={null}
flush(): Promise<void>
```

Flush any buffered audio.

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

Provider configuration (threshold and durations) sent to the Zero Runtime.

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### onVadEvent

```typescript theme={null}
onVadEvent(callback: VadEventCallback): void
```

Register a callback to receive VADResponse events.

<ParamField path="callback" type="VadEventCallback" required />

### processAudio

```typescript theme={null}
processAudio(_audioFrames: Uint8Array, ..._extra: any[]): Promise<void>
```

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

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

***

## VADResponse

Create a VADResponse.

### Constructor

```typescript theme={null}
new VADResponse(init: { eventType: VADEventType; data: VADData; metadata?: Record<string, any> | null; })
```

<ParamField path="eventType" type="VADEventType" required />

<ParamField path="data" type="VADData" required />

<ParamField path="metadata" type="Record<string, any> | null" />

***

## VADData

Create VADData.

### Constructor

```typescript theme={null}
new VADData(init: { isSpeech: boolean; confidence?: number; timestamp?: number; speechDuration?: number; silenceDuration?: number; })
```

<ParamField path="isSpeech" type="boolean" required />

<ParamField path="confidence" type="number" />

<ParamField path="timestamp" type="number" />

<ParamField path="speechDuration" type="number" />

<ParamField path="silenceDuration" type="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

```typescript theme={null}
new EOU(opts: EOUOptions)
```

<ParamField path="threshold" type="number">
  End-of-utterance probability threshold 0-1. Defaults to `0.7`.
</ParamField>

### cleanup

```typescript theme={null}
cleanup(): Promise<void>
```

Tear down provider state.

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### detectEndOfUtterance

```typescript theme={null}
detectEndOfUtterance(chatContext?: any, threshold?: number): boolean
```

Whether the current EOU probability meets `threshold` (or the configured one).

<ParamField path="chatContext" type="any" />

<ParamField path="threshold" type="number" />

<ResponseField name="returns" type="boolean" />

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getEouProbability

```typescript theme={null}
getEouProbability(_chatContext?: any): number
```

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

<ResponseField name="returns" type="number" />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

Provider configuration (threshold) sent to the Zero Runtime.

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### setThreshold

```typescript theme={null}
setThreshold(threshold: number): void
```

Update the end-of-utterance threshold.

<ParamField path="threshold" type="number" required />

***

## FallbackSTT

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

### Constructor

```typescript theme={null}
new FallbackSTT(providers: STT[], opts: FallbackOptions)
```

<ParamField path="providers" type="STT[]" required>
  Providers in priority order; the first is the primary.
</ParamField>

<ParamField path="temporaryDisableSec" type="number">
  Seconds to skip a failing provider before retrying. Defaults to DEFAULT\_TEMPORARY\_DISABLE\_SEC.
</ParamField>

<ParamField path="permanentDisableAfterAttempts" type="number">
  Failed attempts after which a provider is disabled for the session. Defaults to DEFAULT\_PERMANENT\_DISABLE\_AFTER\_ATTEMPTS.
</ParamField>

<ParamField path="recoveryCheckIntervalSec" type="number">
  Seconds between health checks of a disabled provider. Defaults to DEFAULT\_RECOVERY\_CHECK\_INTERVAL\_SEC.
</ParamField>

<ParamField path="latencyThresholdMs" type="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.
</ParamField>

<ParamField path="consecutiveLatencyHits" type="number">
  Consecutive turns over `latencyThresholdMs` before failing over. Defaults to 3.
</ParamField>

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### onSttTranscript

```typescript theme={null}
onSttTranscript(callback: SttTranscriptCallback): void
```

Register a callback to receive transcripts as they are produced.

<ParamField path="callback" type="SttTranscriptCallback" required />

### processAudio

```typescript theme={null}
processAudio(_audioFrames: Uint8Array, _language?: string | null, ..._extra: any[]): Promise<void>
```

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

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### streamTranscribe

```typescript theme={null}
streamTranscribe(_audioStream: AsyncIterable<Uint8Array>, ..._extra: any[]): AsyncIterator<STTResponse>
```

Transcribe a streaming audio source, yielding STTResponses. Override in a custom provider.

<ResponseField name="returns" type="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

```typescript theme={null}
new FallbackLLM(providers: LLM[], opts: FallbackOptions)
```

<ParamField path="providers" type="LLM[]" required>
  Providers in priority order; the first is the primary.
</ParamField>

<ParamField path="temporaryDisableSec" type="number">
  Seconds to skip a failing provider before retrying. Defaults to DEFAULT\_TEMPORARY\_DISABLE\_SEC.
</ParamField>

<ParamField path="permanentDisableAfterAttempts" type="number">
  Failed attempts after which a provider is disabled for the session. Defaults to DEFAULT\_PERMANENT\_DISABLE\_AFTER\_ATTEMPTS.
</ParamField>

<ParamField path="recoveryCheckIntervalSec" type="number">
  Seconds between health checks of a disabled provider. Defaults to DEFAULT\_RECOVERY\_CHECK\_INTERVAL\_SEC.
</ParamField>

<ParamField path="latencyThresholdMs" type="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.
</ParamField>

<ParamField path="consecutiveLatencyHits" type="number">
  Consecutive turns over `latencyThresholdMs` before failing over. Defaults to 3.
</ParamField>

### cancelCurrentGeneration

```typescript theme={null}
cancelCurrentGeneration(): Promise<void>
```

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

### chat

```typescript theme={null}
chat(_messages: any, _opts?: LLMChatOptions): AsyncIterator<LLMResponse>
```

Stream a completion for the given messages, yielding LLMResponse chunks.

<ResponseField name="returns" type="AsyncIterator<LLMResponse>" />

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

***

## FallbackTTS

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

### Constructor

```typescript theme={null}
new FallbackTTS(providers: TTS[], opts: FallbackOptions)
```

<ParamField path="providers" type="TTS[]" required>
  Providers in priority order; the first is the primary.
</ParamField>

<ParamField path="temporaryDisableSec" type="number">
  Seconds to skip a failing provider before retrying. Defaults to DEFAULT\_TEMPORARY\_DISABLE\_SEC.
</ParamField>

<ParamField path="permanentDisableAfterAttempts" type="number">
  Failed attempts after which a provider is disabled for the session. Defaults to DEFAULT\_PERMANENT\_DISABLE\_AFTER\_ATTEMPTS.
</ParamField>

<ParamField path="recoveryCheckIntervalSec" type="number">
  Seconds between health checks of a disabled provider. Defaults to DEFAULT\_RECOVERY\_CHECK\_INTERVAL\_SEC.
</ParamField>

<ParamField path="latencyThresholdMs" type="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.
</ParamField>

<ParamField path="consecutiveLatencyHits" type="number">
  Consecutive turns over `latencyThresholdMs` before failing over. Defaults to 3.
</ParamField>

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### interrupt

```typescript theme={null}
interrupt(): Promise<void>
```

Stop the current synthesis.

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### onFirstAudioByte

```typescript theme={null}
onFirstAudioByte(callback: FirstAudioByteCallback): void
```

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

<ParamField path="callback" type="FirstAudioByteCallback" required />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### synthesize

```typescript theme={null}
synthesize(text: any, ..._extra: any[]): Promise<void>
```

Synthesize and speak `text` on the active session.

<ParamField path="text" type="any" required />

***

## UtteranceHandle

See the class-level description for usage.

### Constructor

```typescript theme={null}
new UtteranceHandle(opts: UtteranceHandleOptions)
```

<ParamField path="utteranceId" type="string">
  Identifier for the utterance. Default: a generated UUID.
</ParamField>

<ParamField path="interruptible" type="boolean">
  Whether the utterance can be interrupted without `force`. Default: `true`.
</ParamField>

### done

```typescript theme={null}
done(): boolean
```

Whether the utterance has finished (completed or interrupted).

<ResponseField name="returns" type="boolean" />

### interrupt

```typescript theme={null}
interrupt(opts: { force?: boolean } = {}): void
```

Interrupt the utterance, marking it done and firing last-audio-byte callbacks.
Has no effect on a non-interruptible utterance unless `force` is `true`.

<ParamField path="opts" type="{ force?: boolean }" />

### markDone

```typescript theme={null}
markDone(): void
```

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

### onLastAudioByte

```typescript theme={null}
onLastAudioByte(cb: () => any): () => any
```

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.

<ParamField path="cb" type="() => any" required />

<ResponseField name="returns" type="() => any" />

### then

```typescript theme={null}
then(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>
```

Makes the handle awaitable; resolves when the utterance finishes.

<ParamField path="onfulfilled" type="((value: void) => TResult1 | PromiseLike<TResult1>) | null" />

<ParamField path="onrejected" type="((reason: any) => TResult2 | PromiseLike<TResult2>) | null" />

<ResponseField name="returns" type="Promise<TResult1 | TResult2>" />

### wait

```typescript theme={null}
wait(): Promise<void>
```

Returns a promise that resolves when the utterance finishes.
