# Gemini 3.1 Flash TTS API

> Google's expressive text-to-speech — natural AI voice with control over tone and emotion.

- **Provider**: Google
- **Model id**: `gemini-3-1-flash-tts`
- **Modality**: music
- **Price**: 2.57 credits

## Overview

Gemini 3.1 Flash 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: `gemini-3-1-flash-tts` |
| input | object | Yes | Input parameters object (see below) |
| callbackUrl | string | No | https URL to receive a signed webhook on completion |

### input object parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| speakers | object[] | Yes | Array of { speaker_id, voice_name, audio_profile, style, pace, accent } |
| dialogue_turns | object[] | Yes | Array of { speaker_id, text } |
| temperature | number | No | Range 0-2 (default: 1) |
| scene | string | No | Text value |
| sample_context | string | No | Text value |

### Request example

```json
{
  "modelId": "gemini-3-1-flash-tts",
  "input": {
    "speakers": [
      {
        "speaker_id": "Speaker 1",
        "voice_name": "Zephyr",
        "audio_profile": "example",
        "style": "Deadpan",
        "pace": "Natural",
        "accent": "Neutral"
      }
    ],
    "dialogue_turns": [
      {
        "speaker_id": "Speaker 1",
        "text": "example"
      }
    ],
    "temperature": 1,
    "scene": "example",
    "sample_context": "example"
  }
}
```

### Response example

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

## Query Task

`GET https://you.bot/api/v1/task/{taskId}?model=gemini-3-1-flash-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 |
| 422 | Parameter validation failed |
| 429 | Request rate limit exceeded |
| 500 | Internal server error |
