# Синтез речи

**API:** Model API

**Endpoint:** `POST /api/v1/audio/speech`

**Tags:** Audio

Use model to select the speech generation model. Channel selection is unavailable for speech generation requests.

## Base URL

- `https://openapi.felo.ai` — Боевая среда

## Authentication

- `FeloBearerAuth` (http bearer) — API-ключ Felo, передаваемый как `Authorization: Bearer <key>`.
- `FeloApiKey` (apiKey in header `X-API-Key`) — API-ключ Felo, передаваемый как `X-API-Key: <key>`.

## Request body

Required: **yes**

### application/json

Schema:

```json
{
  "type": "object",
  "required": [
    "model",
    "input"
  ],
  "additionalProperties": false,
  "properties": {
    "model": {
      "type": "string",
      "maxLength": 256
    },
    "input": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "voice": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "description": "Optional non-blank voice ID. The upstream model determines whether a voice is required and which IDs it accepts. Catalog voices are examples."
    },
    "response_format": {
      "type": "string",
      "enum": [
        "pcm",
        "mp3"
      ],
      "default": "pcm"
    },
    "speed": {
      "type": "number",
      "default": 1,
      "description": "Currently only 1 is supported."
    }
  }
}
```

## Responses

### 200 — Ответ — байты аудио: `audio/mpeg` для MP3 или `audio/pcm` для сырого PCM, не WAV, JSON или SSE. Перед воспроизведением проверьте HTTP-статус и завершение передачи. `--fail` не сохраняет тело HTTP-ошибки в аудиофайл. Удалите неполный файл после обрыва. Параметры воспроизведения PCM уточняйте у канала, не угадывайте. STT оплачивается по `input_audio_second` или token, TTS — по `input_character`. `speech_billing_unit`: `utf16_code_unit` и `unicode_code_point` по-разному считают emoji. Резерв не является пределом расходов; расчёт может быть асинхронным. Отсутствие данных не означает бесплатность. Оба API принимают `X-Felo-Channel` и отправляют запрос в выбранный канал один раз. Отключите автоматические повторы после таймаута или обрыва, включая SDK; сохраните `X-Request-Id` и доступный `X-Generation-Id`. Console Playground пока не поддерживает аудио. `configured_rates` использует зафиксированные ставки и подтверждённый объём; `upstream_cost` — проверенную стоимость поставщика с опубликованной наценкой и скидкой.

**audio/mpeg**

Schema: string, (binary)

```json
{
  "type": "string",
  "format": "binary"
}
```

**audio/pcm**

Schema: string, (binary)

```json
{
  "type": "string",
  "format": "binary"
}
```
