Skip to main content

Audio Endpoints Documentation

The codebase contains two audio synthesis endpoints:
  • /api/audio/speech - Main TTS endpoint supporting REST and streaming modes
  • /api/audio/speech/sse - Dedicated SSE streaming endpoint

Overview

The Audio Synthesis API provides text-to-speech (TTS) capabilities using Google Cloud’s Chirp voice cloning technology with Gemini voices. The API supports both REST and Server-Sent Events (SSE) streaming modes. Base URL: ${NEXT_PUBLIC_BASE_URL} Version: 1.0.0

Authentication

All audio endpoints require API key authentication.

Headers

Getting an API Key

  1. Authenticate with OAuth at /oauth/get-key
  2. Create an API key at /api/auth/api-keys
  3. Save the key securely (shown only once)

Authentication Errors


Endpoints

1. REST Speech Synthesis

POST /api/audio/speech Synthesize speech from text using a specified voice. Returns either a public URL or audio buffer.

Request Body

REST Method Parameters

Response (URL Mode)

Response (Buffer Mode)

Content-Type: audio/wav | audio/pcm | audio/mpeg Headers:
  • Content-Disposition: attachment; filename={id}.{format}
  • X-Voice: Voice name
  • X-Method: ‘rest’
  • X-Chars: Character count
  • X-Format: Output format
Binary audio data in response body.

Example: URL Mode

Response:

Example: Buffer Mode