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

# TTS (Text to Speech)

> Call /audio/speech with the Ruby SDK.

**Method**: `client.generate_speech(...)` or `client.create_speech(...)`.

### Example

```ruby theme={null}
require 'ai_stats_sdk'

client = AIStatsSdk::AIStats.new(api_key: ENV.fetch("AI_STATS_API_KEY"))
audio = client.generate_speech(
  model: 'openai/gpt-4o-mini-tts',
  input: 'Hello world',
  voice: 'alloy',
  format: 'mp3'
)
```

### Key parameters

* `model` (required): TTS-capable model id.
* `input` (required): Text to synthesize.
* `voice`: Voice preset (model-dependent, e.g., `alloy`).
* `format`: `mp3`, `wav`, `flac`, etc.
* `speed`: Playback speed multiplier (typically 0.25–4).

### Returns

Audio binary
