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

# Text to speech

> Generate speech from text with Grok Voice TTS and Gemini Flash TTS through the OpenAI-compatible audio speech endpoint.

`POST /v1/audio/speech` takes text and returns audio bytes. Two models serve it:

| Model                                 | Billing                                            | Formats       | Voices                                     |
| ------------------------------------- | -------------------------------------------------- | ------------- | ------------------------------------------ |
| `xai/grok-voice-tts-1.0`              | \$15.00 / 1M characters                            | mp3, wav, pcm | 26 voices, including eve, carina and zagan |
| `google/gemini-3.1-flash-tts-preview` | $1.00 / 1M input tokens, $20.00 / 1M output tokens | wav, pcm      | 30 voices, including Kore, Puck and Zephyr |

## Generate speech

```bash theme={null}
curl https://api.impossibl.com/v1/audio/speech \
  -H "Authorization: Bearer imp-rt-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "xai/grok-voice-tts-1.0",
    "input": "hello there, this is a test",
    "voice": "eve"
  }' \
  --output speech.mp3
```

The response body is the audio itself, so write it to a file. Failed upstream
requests are not charged.

## Voices

Voices are the provider's own ids, not OpenAI aliases: `eve` for Grok, `Kore` for
Gemini. Ids match case-insensitively, so `EVE` and `kore` work too. An unknown voice
returns a 400 listing the ones that model has. `GET /v1/models` carries the full list
per model, so nothing needs to be hardcoded.

```bash theme={null}
curl https://api.impossibl.com/v1/models \
  -H "Authorization: Bearer imp-rt-..." | jq '.data[] | select(.endpoints == ["/v1/audio/speech"]) | {id, voices}'
```

## Audio formats

Each model defaults to its native format: mp3 for Grok, wav for Gemini. Gemini
generates 24 kHz mono PCM and nothing else, so it serves `wav` and `pcm` only.
Asking a model for a format it cannot produce returns a 400 rather than quietly
substituting another one.

```bash theme={null}
curl https://api.impossibl.com/v1/audio/speech \
  -H "Authorization: Bearer imp-rt-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.1-flash-tts-preview",
    "input": "hello there, this is a test",
    "voice": "Kore",
    "response_format": "wav"
  }' \
  --output speech.wav
```

## Limits and billing units

Grok Voice bills per character of input, capped at 15,000 characters per request,
and `speed` accepts 0.7 to 1.5. Gemini Flash TTS bills tokens the way every other
Gemini model does and accepts up to 8,192 input tokens. It has no rate control, so
a `speed` other than 1 returns a 400 instead of quietly giving you normal-speed audio.

Both models accept inline expressive tags in `input` to steer delivery.
