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

# Openai

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

## OpenAISTT

OpenAI speech-to-text (STT) transcriber.

### Constructor

```typescript theme={null}
new OpenAISTT(opts: OpenAISTTOptions)
```

<ParamField path="apiKey" type="string | null">
  OpenAI API key. Defaults to the `OPENAI_API_KEY` environment variable.
</ParamField>

<ParamField path="model" type="OpenAISTTModel | string">
  Transcription model id. Default `'gpt-4o-transcribe'`.
</ParamField>

<ParamField path="language" type="string">
  Spoken language as a BCP-47/ISO code. Default `'en'`.
</ParamField>

<ParamField path="stream" type="boolean">
  Stream partial transcripts as audio arrives. Default `true`.
</ParamField>

<ParamField path="inputSampleRate" type="number">
  Sample rate (Hz) of the audio sent in. Default `48000`.
</ParamField>

<ParamField path="outputSampleRate" type="number">
  Sample rate in Hz that input audio is resampled to. Default `24000`.
</ParamField>

<ParamField path="prompt" type="string | null">
  Optional prompt to bias transcription. Default `null`.
</ParamField>

<ParamField path="turnDetection" type="string">
  Turn-detection mode. Default `'server_vad'`.
</ParamField>

<ParamField path="vadThreshold" type="number | null">
  VAD speech-probability threshold. Default `null` (provider default).
</ParamField>

<ParamField path="vadPrefixPaddingMs" type="number | null">
  Audio padding (ms) prepended before detected speech. Default `null`.
</ParamField>

<ParamField path="vadSilenceDurationMs" type="number | null">
  Trailing silence (ms) that ends a turn. Default `null`.
</ParamField>

<ParamField path="noiseReduction" type="string | null">
  Noise-reduction profile, e.g. `'near_field'`/`'far_field'`. Default `'near_field'`.
</ParamField>

<ParamField path="responseFormat" type="string">
  Transcript response format. Default `'json'`.
</ParamField>

<ParamField path="baseUrl" type="string | null">
  Override the API base URL. Default `null`.
</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>" />

***

## OpenAISTTModel

Supported OpenAI STT transcription model ids.

```typescript theme={null}
type OpenAISTTModel = | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe-diarize' | 'whisper-1'
```
