# Grok TTS API

> xAI's Grok text-to-speech — turn a script of up to 60,000 characters into natural speech in 26 voices and 20+ languages, with inline speech tags like [laugh] and <whisper> for expressive delivery.

- **Provider**: Grok
- **Model id**: `grok-tts`
- **Modality**: music
- **Price**: 1.35 credits /1k characters

## Overview

Grok TTS is called in two steps: create a generation task, then poll the task until the result is ready.

## Authentication

All requests require a Bearer Token in the request header:

```
Authorization: Bearer YOUR_API_KEY
```

## Create Task

`POST https://you.bot/api/v1/generate`

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| modelId | string | Yes | Model id: `grok-tts` |
| input | object | Yes | Input parameters object (see below) |
| callbackUrl | string | No | https URL we POST the finished task to. Signed with `X-Webhook-Signature` once you create a webhook signing key in Dashboard → Settings |

### input object parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| text | string | Yes | Up to 60,000 characters. Add speech tags for delivery, e.g. [pause], [laugh], <whisper>…</whisper>. Billed per character. Max 60000 characters. (example: Welcome to you.bot. [pause] This voice was generated by Grok text-to-speech.) |
| voice_id | string | Yes | Options: eve \| ara \| leo \| rex \| sal \| atlas \| altair \| carina \| castor \| celeste \| cosmo \| helios \| helix \| iris \| kepler \| lumen \| luna \| lux \| naksh \| orion \| perseus \| rigel \| sirius \| ursa \| zagan \| zenith (default: eve) |
| language | string | Yes | Auto-detect reads the language from the text. Any voice can speak any language. (options: auto \| en \| ar-EG \| ar-SA \| ar-AE \| bn \| zh \| fr \| de \| hi \| id \| it \| ja \| ko \| pt-BR \| pt-PT \| ru \| es-MX \| es-ES \| tr \| vi) (default: auto) |
| speed | number | No | 1.0 is normal speed. Lower is slower, higher is faster. (range 0.7-1.5) (default: 1) |
| format | string | No | Options: mp3 \| wav (default: mp3) |

### Request example

```json
{
  "modelId": "grok-tts",
  "input": {
    "text": "Welcome to you.bot. [pause] This voice was generated by Grok text-to-speech.",
    "voice_id": "eve",
    "language": "auto",
    "speed": 1,
    "format": "mp3"
  }
}
```

### Response example

```json
{
  "taskId": "281e5b0…f39b9",
  "creditsCharged": 0.1
}
```

## Query Task

`GET https://you.bot/api/v1/task/{taskId}?model=grok-tts`

When `state` is `success`, the output is in `resultUrls`: `{ "state": "success", "resultUrls": [ ... ] }`. (Text models return inline in the create response.)

## Error Codes

| Code | Description |
|------|-------------|
| 200 | Request successful |
| 400 | Invalid request parameters |
| 401 | Authentication failed — check API Key |
| 402 | Insufficient account balance |
| 403 | IP not allowed for this key, or the key is restricted to other models |
| 404 | Task not found, or it has expired |
| 409 | Duplicate request — an identical submit arrived moments ago. Nothing was charged; retry is safe |
| 413 | Payload too large — see the character and file-size limits for this model |
| 429 | Rate limit exceeded — retry after the Retry-After header |
| 500 | Internal server error |
| 504 | Upstream timed out — nothing was delivered; retry is safe |
