Skip to main content

Endpoint

Generates audio from text input using text-to-speech models.

Request

Headers

string
required
Must be application/json
string
required
The AI provider to use (e.g., openai)
string
required
Your API key for the specified provider

Body Parameters

string
required
The TTS model to use (e.g., tts-1, tts-1-hd)
string
required
The text to convert to speech. Maximum length is 4096 characters.
string
required
The voice to use for speech generation. Available voices: alloy, echo, fable, onyx, nova, shimmer
string
default:"mp3"
The audio format. Options: mp3, opus, aac, flac, wav, pcm
number
Playback speed (0.25 to 4.0)

Response

Returns the audio file content as a binary stream.
header
The MIME type of the audio file (e.g., audio/mpeg for MP3)

Examples

Basic Text-to-Speech

Python SDK

JavaScript SDK

High Definition Audio

Different Voice Options

Different Audio Formats

Adjust Speech Speed

Streaming Audio

Long Text Example

Voice Characteristics

  • alloy: Neutral and balanced, good for general use
  • echo: Clear and articulate, professional tone
  • fable: Warm and expressive, storytelling quality
  • onyx: Deep and authoritative, formal tone
  • nova: Friendly and energetic, engaging quality
  • shimmer: Bright and cheerful, conversational tone

Model Comparison

tts-1 (Standard)

  • Lower latency
  • Good quality
  • Suitable for real-time applications
  • More cost-effective

tts-1-hd (High Definition)

  • Higher quality audio
  • More natural-sounding
  • Slightly higher latency
  • Better for pre-recorded content

Audio Format Specifications

  • mp3: Most compatible, good compression (default)
  • opus: Best for internet streaming, low latency
  • aac: Good quality-to-size ratio
  • flac: Lossless compression, larger files
  • wav: Uncompressed, largest files
  • pcm: Raw audio data

Best Practices

  1. Choose the Right Model: Use tts-1 for real-time, tts-1-hd for quality
  2. Text Length: Keep under 4096 characters per request
  3. Voice Selection: Test different voices for your use case
  4. Format Selection: Use MP3 for general use, OPUS for streaming
  5. Speed Adjustment: Use 0.9-1.1 for natural variations

Use Cases

  • Accessibility: Convert text content to audio for visually impaired users
  • Content Creation: Generate voiceovers for videos and presentations
  • E-learning: Create audio versions of educational content
  • Audiobooks: Convert written content to audio format
  • Voice Assistants: Generate spoken responses for AI assistants
  • Notifications: Create audio alerts and announcements