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

# Smallestai

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

## SmallestAITTS

Smallest AI text-to-speech (TTS) synthesizer.

### Constructor

```typescript theme={null}
new SmallestAITTS(opts: SmallestAITTSOptions)
```

<ParamField path="apiKey" type="string">
  Smallest AI API key. Defaults to the `SMALLESTAI_API_KEY` environment variable.
</ParamField>

<ParamField path="voice" type="string">
  Voice name for synthesis (e.g. `'magnus'`, `'lauren'`). Takes precedence over `voiceId`. Default `'magnus'`.
</ParamField>

<ParamField path="voiceId" type="string">
  Voice id; compatibility alias for `voice`. Ignored when `voice` is also set.
</ParamField>

<ParamField path="model" type="SmallestAITTSModel | string">
  TTS model id. Default `'lightning_v3.1'`.
</ParamField>

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

<ParamField path="language" type="string">
  ISO 639-1 language code for the target voice. Default `'en'`.
</ParamField>

<ParamField path="speed" type="number | null">
  Speaking rate multiplier; `null` uses the model default. Default `null`.
</ParamField>

<ParamField path="stream" type="boolean">
  Stream audio from the model. Default `true`.
</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 />

***

## SmallestAITTSModel

Supported Smallest AI TTS model names.

```typescript theme={null}
type SmallestAITTSModel = 'lightning_v3.1' | 'lightning_v3.1_pro' | 'lightning'
```
