Prompt
tts api mp3
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
If you want to use a TTS (text-to-speech) API to return MP3 audio, the exact setup depends on the provider.
Here are common options:
Typical API flow
- Send text to the TTS endpoint
- Set the response format to
mp3 - Receive audio bytes
- Save/play the file as
.mp3
Example request pattern
curl -X POST "https://api.example.com/tts" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello world",
"format": "mp3",
"voice": "en-US"
}' --output output.mp3
Python example
import requests
url = "https://api.example.com/tts"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"text": "Hello world",
"format": "mp3"
}
r = requests.post(url, headers=headers, json=data)
with open("output.mp3", "wb") as f:
f.write(r.content)
If you mean a specific service
Popular TTS APIs that support MP3:
- OpenAI TTS
- Google Cloud Text-to-Speech
- Amazon Polly
- Azure Speech
If you want, I can give you:
- a specific OpenAI TTS MP3 example
- a Node.js example
- or a FastAPI endpoint that converts text to MP3