Skip to main content
POST
/
v1
/
audio
/
speech
curl --request POST \
  --url https://api.apimart.ai/v1/audio/speech \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-4o-mini-tts",
    "input": "The quick brown fox jumps over the lazy dog.",
    "voice": "alloy",
    "response_format": "opus",
    "speed": 1.0
  }' \
  --output speech.opus
Binary audio data stream
curl --request POST \
  --url https://api.apimart.ai/v1/audio/speech \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-4o-mini-tts",
    "input": "The quick brown fox jumps over the lazy dog.",
    "voice": "alloy",
    "response_format": "opus",
    "speed": 1.0
  }' \
  --output speech.opus
Binary audio data stream

Authorizations

Authorization
string
required
All APIs require Bearer Token authenticationGet API Key:Visit API Key Management Page to get your API KeyAdd to request header:
Authorization: Bearer YOUR_API_KEY

Body

model
string
required
TTS model nameAvailable models:
  • gpt-4o-mini-tts - GPT-4o Mini TTS model (mp3 format not supported yet)
Example: "gpt-4o-mini-tts"
input
string
required
The text to convert to speechMaximum length: 4096 charactersExample: "The quick brown fox jumps over the lazy dog."
voice
string
required
Voice selectionAvailable voices:
  • alloy - Neutral, balanced voice
  • echo - Male, calm voice
  • fable - British, narrative voice
  • onyx - Male, deep voice
  • nova - Female, energetic voice
  • shimmer - Female, gentle voice
Example: "alloy"
response_format
string
default:"mp3"
Audio output formatSupported formats:
  • mp3 - MP3 format (default)
  • opus - Opus format, for internet streaming
  • aac - AAC format
  • flac - FLAC format, lossless compression
  • wav - WAV format, uncompressed
  • pcm - PCM format, raw audio data
Example: "mp3"
speed
number
default:"1.0"
Speech playback speedRange: 0.25 to 4.0
  • 0.25 - Slowest speed (1/4x)
  • 1.0 - Normal speed (default)
  • 4.0 - Fastest speed (4x)
Example: 1.0

Response

Returns binary audio data stream on success, which can be saved as an audio file or played directly. Returns JSON formatted error information on error, including error code, message, and type.