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

# Retrieve Async Audio

> <b>Retrieve audio generated by async text-to-speech endpoints</b>

This endpoint retrieves audio files generated by both async TTS endpoints.
Requires the mediaId and JWT token returned from the async synthesis request.

**Behavior depends on the originating endpoint:**

**From `/text-to-speech-async`:**
- Returns complete audio file when ready
- Typically available within 1-2 seconds
- Best for bots and webhooks needing complete files

**From `/text-to-speech/stream-async`:**
- Supports chunked streaming with ~300ms first chunk latency
- Audio streams progressively as it's generated
- Best for frontend apps and real-time playback

**Key features:**
- **Direct access** - Can be accessed directly by clients without your API key
- **Secure** - JWT token ensures only authorized access to the audio
- **CDN-ready** - Optimized for content delivery networks




## OpenAPI

````yaml get /synthesis/stream-audio/{mediaId}
openapi: 3.1.0
info:
  title: UpliftAI API
  version: 1.0.0
  description: >
    API for UpliftAI messaging, media handling, and text-to-speech capabilities.
    This API enables real-time communication

    with AI assistants, supporting various content types including text, images,
    audio,

    and documents. It provides both synchronous and asynchronous messaging
    capabilities

    with webhook support for real-time updates. The API also supports
    text-to-speech synthesis

    and phrase replacement configuration.
servers:
  - url: https://api.upliftai.org/v1
    description: Version 1 API
security: []
paths:
  /synthesis/stream-audio/{mediaId}:
    get:
      summary: Retrieve Async Audio
      description: >
        <b>Retrieve audio generated by async text-to-speech endpoints</b>


        This endpoint retrieves audio files generated by both async TTS
        endpoints.

        Requires the mediaId and JWT token returned from the async synthesis
        request.


        **Behavior depends on the originating endpoint:**


        **From `/text-to-speech-async`:**

        - Returns complete audio file when ready

        - Typically available within 1-2 seconds

        - Best for bots and webhooks needing complete files


        **From `/text-to-speech/stream-async`:**

        - Supports chunked streaming with ~300ms first chunk latency

        - Audio streams progressively as it's generated

        - Best for frontend apps and real-time playback


        **Key features:**

        - **Direct access** - Can be accessed directly by clients without your
        API key

        - **Secure** - JWT token ensures only authorized access to the audio

        - **CDN-ready** - Optimized for content delivery networks
      parameters:
        - name: mediaId
          in: path
          required: true
          description: The media ID returned from the async TTS request
          schema:
            type: string
            example: media_abc123xyz
        - name: token
          in: query
          required: true
          description: JWT token for authentication
          schema:
            type: string
            example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
      responses:
        '200':
          description: Audio file retrieved successfully
          content:
            audio/*:
              schema:
                type: string
                format: binary
          headers:
            Content-Type:
              schema:
                type: string
              description: Audio MIME type (e.g., audio/mp3)
            Content-Length:
              schema:
                type: integer
              description: Size of the audio file in bytes
            Cache-Control:
              schema:
                type: string
              description: Cache directives for CDN
        '401':
          description: Invalid or expired token
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Invalid or expired token
        '404':
          description: Media not found or expired
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Media not found or expired
      x-codeSamples:
        - lang: cURL
          label: Direct retrieval
          source: >
            curl -X GET
            "https://api.upliftai.org/v1/synthesis/stream-audio/media_abc123xyz?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
            \
              -o output.mp3
        - lang: HTML
          label: Embed in web page
          source: |
            <!-- Direct embedding in HTML -->
            <audio controls>
              <source src="https://api.upliftai.org/v1/synthesis/stream-audio/media_abc123xyz?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." type="audio/mp3">
            </audio>

````