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

# Синтез речи

> Озвучивает текст и возвращает аудиофайл. Нужен AI-ключ с правом voice.

Преобразует текст в аудио. Используйте AI-ключ с правом `voice`. По умолчанию результат возвращается файлом MP3. Чтобы получать звук потоком в формате OpenAI, передайте `stream_format: "sse"`: придут события `speech.audio.delta` и `speech.audio.done`.


## OpenAPI

````yaml ru/openapi/ru-openai-api-openapi.yaml POST /v1/audio/speech
openapi: 3.1.0
info:
  title: ER:LC Россия — OpenAI-Совместимый API
  version: 1.0.0
  description: >-
    OpenAI-совместимые методы Chat Completions, получения моделей и синтеза речи
    ER:LC Россия. Поддерживаемые параметры приведены в описании каждого метода.
servers:
  - url: https://api.erlcrussia.com
    description: Основной сервер
  - url: https://api.erlcrussia.xyz
    description: Резервный сервер
security: []
paths:
  /v1/audio/speech:
    post:
      tags:
        - Audio
      summary: Синтез речи
      description: Озвучивает текст и возвращает аудиофайл. Нужен AI-ключ с правом voice.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - input
              properties:
                model:
                  type: string
                  enum:
                    - emmy-voice-1
                    - supertonic
                    - tts-1
                    - tts-1-hd
                  default: emmy-voice-1
                input:
                  type: string
                  minLength: 1
                  maxLength: 6000
                  description: Текст для озвучивания.
                language:
                  type: string
                  enum:
                    - ru
                    - uk
                    - be
                    - en
                    - es
                    - it
                    - fr
                    - zh
                    - ja
                    - ko
                  default: ru
                voice:
                  type: string
                  enum:
                    - default
                    - F1
                    - F2
                    - emmy
                    - emmy-v2
                    - alloy
                    - nova
                  default: default
                response_format:
                  type: string
                  enum:
                    - mp3
                    - wav
                    - pcm
                    - aac
                    - flac
                    - opus
                  default: mp3
                speed:
                  type: number
                  minimum: 0.25
                  maximum: 4
                  default: 1
                stream:
                  type: boolean
                  default: false
                  description: >-
                    Расширение ER:LC Россия: поток строк NDJSON по предложениям.
                    Для формата OpenAI используйте `stream_format: sse`.
                stream_format:
                  type: string
                  enum:
                    - audio
                    - sse
                  default: audio
                  description: >-
                    `audio` — файл целиком (по умолчанию), `sse` — поток событий
                    `speech.audio.delta` и `speech.audio.done`.
            example:
              model: emmy-voice-1
              input: Привет! Чем я могу помочь?
              language: ru
              voice: F1
              response_format: mp3
              speed: 1
      responses:
        '200':
          description: >-
            Аудиофайл в выбранном формате. При stream=true возвращаются строки
            NDJSON с потоковыми данными.
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
            application/octet-stream:
              schema:
                type: string
                format: binary
            application/x-ndjson:
              schema:
                type: string
            text/event-stream:
              schema:
                type: string
                description: >-
                  Поток событий при `stream_format: sse`: `speech.audio.delta` с
                  аудио в base64 и `speech.audio.done` с `usage`.
              example: >+
                data: {"type":"speech.audio.delta","audio":"SUQzBAAAAAAA..."}


                data:
                {"type":"speech.audio.done","usage":{"input_tokens":7,"output_tokens":0,"total_tokens":7}}

          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            openai-processing-ms:
              $ref: '#/components/headers/ProcessingMs'
            x-ratelimit-limit-requests:
              $ref: '#/components/headers/RateLimitRequests'
            x-ratelimit-remaining-requests:
              $ref: '#/components/headers/RateLimitRemainingRequests'
            x-ratelimit-reset-requests:
              $ref: '#/components/headers/RateLimitResetRequests'
        '400':
          description: Некорректное тело запроса.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: >-
                    We could not parse the JSON body of your request. Make sure
                    it is valid JSON.
                  type: invalid_request_error
                  param: null
                  code: null
                  erlc_code: '5034'
        '401':
          description: Ключ не передан или недействителен.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: >-
                    Incorrect API key provided. Check the key or create a new
                    one in the dashboard.
                  type: invalid_request_error
                  param: null
                  code: invalid_api_key
                  erlc_code: '5008'
        '429':
          description: >-
            Превышен лимит запросов (`type: requests`) или закончились
            AI-кредиты (`type: insufficient_quota`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                rate_limit:
                  value:
                    error:
                      message: Rate limit reached. Please slow down and retry later.
                      type: requests
                      param: null
                      code: rate_limit_exceeded
                      erlc_code: '5016'
                insufficient_quota:
                  value:
                    error:
                      message: >-
                        You exceeded your current quota, please check your plan
                        and billing details.
                      type: insufficient_quota
                      param: null
                      code: insufficient_quota
                      erlc_code: '5038'
        '503':
          description: Сервис временно недоступен.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: Speech synthesis unavailable
                  type: server_error
                  param: null
                  code: null
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  headers:
    RequestId:
      description: Идентификатор запроса для поддержки.
      schema:
        type: string
        example: req_8f2c1e9b4a7d4c0e9f1a2b3c4d5e6f70
    ProcessingMs:
      description: Время обработки запроса в миллисекундах.
      schema:
        type: integer
        example: 412
    RateLimitRequests:
      description: Лимит запросов в текущем окне.
      schema:
        type: integer
        example: 120
    RateLimitRemainingRequests:
      description: Сколько запросов осталось в текущем окне.
      schema:
        type: integer
        example: 119
    RateLimitResetRequests:
      description: Через сколько сбросится лимит, например `1s` или `6m0s`.
      schema:
        type: string
        example: 1s
  schemas:
    ErrorResponse:
      type: object
      description: >-
        Ошибка в формате OpenAI. `code` — строковый код OpenAI
        (`invalid_api_key`, `model_not_found`, `insufficient_quota`,
        `rate_limit_exceeded`) или `null`. Числовой код ER:LC Россия — в
        `erlc_code`, см. [коды ошибок](/ru/documentation/error-codes).
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Insufficient AI Credits
            type:
              type: string
              enum:
                - invalid_request_error
                - insufficient_quota
                - requests
                - server_error
              example: insufficient_quota
            param:
              type:
                - string
                - 'null'
              example: null
            code:
              type:
                - string
                - 'null'
              example: insufficient_quota
            erlc_code:
              type: string
              description: ER:LC Russia numeric error code.
              example: '5038'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Передача токена авторизации в заголовке Authorization: Bearer <token>.'
    ApiKeyAuth:
      type: apiKey
      in: header
      name: erlcrussia-api-ai-key
      description: Ключ в заголовке erlcrussia-api-ai-key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.