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

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

<Card title="Usage guide" icon="book" href="/plugins/tts/smallestai" horizontal>
  Setup, environment variables, and Python/JavaScript/Go usage examples.
</Card>

## SmallestAITTS

Smallest AI Lightning TTS plugin for ultra-low-latency speech synthesis.

Uses Smallest AI's Lightning v3.1 model (optimised for real-time voice
agents) to stream synthesised audio with minimal time-to-first-byte.
Supports 12 languages and a large catalogue of pre-built voices.

### Constructor

```python theme={null}
SmallestAITTS(*, api_key: 'str | None' = None, voice: 'Optional[str]' = None, voice_id: 'Optional[str]' = None, model: 'SmallestAITTSModel | str' = 'lightning_v3.1', sample_rate: 'int' = 24000, language: 'str' = 'en', speed: 'Optional[float]' = None, stream: 'bool' = True, **kwargs) -> 'None'
```

<ParamField path="api_key" type="str | None">
  Smallest AI API key.  Falls back to the `SMALLESTAI_API_KEY` environment variable when `None`.
</ParamField>

<ParamField path="voice" type="Optional[str]">
  Voice name to use for synthesis (e.g. `'magnus'`, `'lauren'`, `'meher'`, `'devansh'`).  Takes precedence over `voice_id` when both are provided.  Defaults to `'magnus'` when neither argument is given.
</ParamField>

<ParamField path="voice_id" type="Optional[str]">
  Alias for `voice`; provided for API-compatibility. Ignored when `voice` is also set.
</ParamField>

<ParamField path="model" type="SmallestAITTSModel | str" default="lightning_v3.1">
  Smallest AI model ID.  Defaults to `'lightning_v3.1'`. `'lightning_v3.1_pro'` is the premium variant with a different per-language voice catalogue.
</ParamField>

<ParamField path="sample_rate" type="int" default="24000">
  Output audio sample rate in Hz.  Defaults to `24000`.  Supported values: `8000`, `16000`, `24000`, `44100`.
</ParamField>

<ParamField path="language" type="str" default="en">
  ISO 639-1 language code for the target voice.  Defaults to `'en'`.  Supported values: `'en'`, `'hi'`, `'mr'`, `'kn'`, `'ta'`, `'bn'`, `'gu'`, `'te'`, `'ml'`, `'pa'`, `'or'`, `'es'`.
</ParamField>

<ParamField path="speed" type="Optional[float]">
  Speaking rate multiplier relative to the voice default. `1.0` is normal speed; `None` (default) uses the model default.
</ParamField>

<ParamField path="stream" type="bool" default="True">
  When `True` (default), audio is returned as a stream of chunks for lower latency.  Set to `False` for a single synchronous response.
</ParamField>

### aclose

```python theme={null}
def aclose(self) -> 'None'
```

Release any resources held by the provider.

### emit

```python theme={null}
def emit(self, event: 'T', *args: 'Any') -> 'None'
```

Emit an event, invoking all registered handlers with the given arguments.

Handlers are called in registration order. Coroutine handlers are
scheduled on the running event loop. If the emitter is closed, the call
is a no-op.

<ParamField path="event" type="T" required>
  The event to emit.
</ParamField>

### interrupt

```python theme={null}
def interrupt(self) -> 'None'
```

Interrupt and cancel the current synthesis for the active session, if any.

### off

```python theme={null}
def off(self, event: 'T', callback: 'Callable[..., Any]') -> 'None'
```

Remove a previously registered handler for an event.

If the handler is not registered for the event, the call is a no-op.

<ParamField path="event" type="T" required>
  The event the handler was registered for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any]" required>
  The handler to remove.
</ParamField>

### on

```python theme={null}
def on(self, event: 'T', callback: 'Callable[..., Any] | None' = None) -> 'Callable[..., Any]'
```

Register a handler for an event.

Can be used directly by passing a callback, or as a decorator when
`callback` is omitted.

<ParamField path="event" type="T" required>
  The event to listen for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any] | None">
  The handler to invoke when the event is emitted. If `None`, a decorator is returned that registers the decorated function.
</ParamField>

<ResponseField name="returns" type="Callable[..., Any]">
  The registered callback when `callback` is provided, otherwise a decorator that registers and returns the function it wraps.
</ResponseField>

### on\_first\_audio\_byte

```python theme={null}
def on_first_audio_byte(self, callback: "'Callable[[int, int], Awaitable[None] | None]'") -> 'None'
```

Register the callback invoked when the first audio byte is produced.

<ParamField path="callback" type="'Callable[[int, int], Awaitable[None] | None]'" required>
  A callable, optionally async, invoked with synthesis timing information when the first audio byte is emitted.
</ParamField>

### synthesize

```python theme={null}
def synthesize(self, text: 'Any', **kwargs: 'Any') -> 'None'
```

Synthesize the given text into speech.

Implementations should convert the text to audio. The default behavior
forwards the text to the active session for playback when one is present.

<ParamField path="text" type="Any" required>
  The text to synthesize; coerced to a string if needed.
</ParamField>

***

## SmallestAITTSModel

```python theme={null}
SmallestAITTSModel = typing.Literal['lightning_v3.1', 'lightning_v3.1_pro', 'lightning']
```
