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

# Assemblyai

> JavaScript API reference for the assemblyai speech-to-text plugin.

## AssemblyAISTT

AssemblyAI speech-to-text provider.

Creates a configured AssemblyAI streaming STT provider for use in a voice agent.

### Constructor

```typescript theme={null}
new AssemblyAISTT(opts: AssemblyAISTTOptions)
```

<ParamField path="apiKey" type="string | null">
  AssemblyAI API key. Falls back to the `ASSEMBLYAI_API_KEY` env var, then `null`.
</ParamField>

<ParamField path="language" type="string">
  Transcription language code. Default: `'en-US'`.
</ParamField>

<ParamField path="inputSampleRate" type="number">
  Input audio sample rate in Hz. Default: `48000`.
</ParamField>

<ParamField path="targetSampleRate" type="number">
  Target output sample rate in Hz (alias of `outputSampleRate`). Default: `16000`.
</ParamField>

<ParamField path="outputSampleRate" type="number">
  Output audio sample rate in Hz. Default: `16000`.
</ParamField>

<ParamField path="encoding" type="string">
  Audio encoding. Default: `'pcm_s16le'`.
</ParamField>

<ParamField path="formatTurns" type="boolean">
  Whether to apply turn formatting (punctuation/casing). Default: `true`.
</ParamField>

<ParamField path="keytermsPrompt" type="string[] | null">
  Keyterms to bias recognition toward. Default: `null`.
</ParamField>

<ParamField path="endOfTurnConfidenceThreshold" type="number">
  Confidence threshold for declaring end of turn. Range `0`-`1`. Default: `0.4`.
</ParamField>

<ParamField path="minEndOfTurnSilenceWhenConfident" type="number">
  Minimum silence (ms) before end of turn when confidence is high. Default: `560`.
</ParamField>

<ParamField path="maxTurnSilence" type="number">
  Maximum silence (ms) allowed within a turn. Default: `2400`.
</ParamField>

<ParamField path="speechModel" type="AssemblyAISTTModel | string">
  Speech model to use. Default: `'universal-streaming-english'`.
</ParamField>

<ParamField path="languageDetection" type="boolean">
  Enable automatic language detection. Default: `false`.
</ParamField>

<ParamField path="baseUrl" type="string | null">
  Override the provider base URL. Default: `null`.
</ParamField>

<ParamField path="region" type="string">
  Service region. Default: `'US'`.
</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>" />

***

## AssemblyAISTTModel

Supported AssemblyAI STT model names.

```typescript theme={null}
type AssemblyAISTTModel = 'universal-streaming-english' | 'universal-streaming-multilingual'
```
