> ## Documentation Index
> Fetch the complete documentation index at: https://smallestai-ff1e543d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Lightning v3.1 SSE

> Stream speech for given text using the Lightning v3.1 SSE API

## Overview

The Lightning v3.1 SSE API provides real-time text-to-speech streaming capabilities with natural, expressive voice synthesis. This API uses Server-Sent Events (SSE) to deliver audio chunks as they're generated, enabling low-latency audio playback without waiting for the entire audio file to process.

Lightning v3.1 is a 44 kHz model that produces natural, expressive, and realistic speech, with support for voice cloning.

## When to Use

* **Interactive Applications**: Perfect for chatbots, virtual assistants, and other applications requiring immediate voice responses
* **Long-Form Content**: Efficiently stream audio for articles, stories, or other long-form content without buffering delays
* **Voice User Interfaces**: Create natural-sounding voice interfaces with minimal perceived latency
* **Accessibility Solutions**: Provide real-time audio versions of written content for users with visual impairments

## How It Works

1. **Make a POST Request**: Send your text and voice settings to the API endpoint
2. **Receive Audio Chunks**: The API processes your text and streams audio back as base64-encoded chunks with 1024 byte size
3. **Process the Stream**: Handle the SSE events to decode and play audio chunks sequentially
4. **End of Stream**: The API sends a completion event when all audio has been delivered


## OpenAPI

````yaml POST /waves/v1/lightning-v3.1/stream
openapi: 3.0.1
info:
  title: Text-to-Speech API
  description: |
    API for Waves text-to-speech models.
    Featuring Lightning v2 and Lightning v3.1 models.
  version: 1.0.0
servers:
  - url: https://api.smallest.ai
    description: Waves API server
security: []
paths:
  /waves/v1/lightning-v3.1/stream:
    post:
      tags:
        - Lightning V3.1
      summary: Stream speech from text (Lightning V3.1)
      description: >-
        Converts provided text to speech using the Lightning V3.1 model with
        streaming response.
      operationId: streamLightningV31Speech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LightningV31Request'
      responses:
        '200':
          description: Synthesized speech retrieved successfully.
          content:
            text/event-stream:
              example:
                data: |
                  event: chunk
                  data: <WAV_DATA>
                  done: false
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: InvalidRequest
                message: The 'text' field is required.
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Unauthorized
                message: Bearer token is missing or invalid.
        '500':
          description: Server error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: InternalServerError
                message: An unexpected error occurred.
      security:
        - bearerAuth: []
components:
  schemas:
    LightningV31Request:
      type: object
      required:
        - text
        - voice_id
      properties:
        text:
          type: string
          description: The text to convert to speech.
        voice_id:
          type: string
          description: The voice identifier to use for speech generation.
        sample_rate:
          type: integer
          description: The sample rate for the generated audio.
          enum:
            - 8000
            - 16000
            - 24000
            - 44100
          default: 44100
        speed:
          type: number
          description: The speed of the generated speech.
          minimum: 0.5
          maximum: 2
          default: 1
        language:
          type: string
          description: >-
            Language code for text normalization (e.g., how numbers, dates, and
            abbreviations are spelled out). Set to 'auto' for automatic language
            detection, or specify a language code like 'en' or 'hi'.
          default: auto
          enum:
            - auto
            - en
            - hi
            - ta
            - es
        output_format:
          type: string
          description: The format of the output audio.
          default: pcm
          enum:
            - pcm
            - mp3
            - wav
            - mulaw
        pronunciation_dicts:
          type: array
          items:
            type: string
            description: >-
              The ID of the pronunciation dictionary to use for speech
              generation.
          description: >-
            The IDs of the pronunciation dictionaries to use for speech
            generation.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error type.
        message:
          type: string
          description: Error message.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <api_key>`, where
        <api_key> is your api key.

````