/audio/speech
Overview
| Feature | Supported | Notes |
|---|---|---|
| Cost Tracking | ✅ | Works with all supported models |
| Logging | ✅ | Works across all integrations |
| Fallbacks | ✅ | Works between supported models |
| Loadbalancing | ✅ | Works between supported models |
| Supported Providers | OpenAI, Azure OpenAI, Vertex AI, AWS Polly, ElevenLabs, MiniMax |
Quick Start
Python
from pathlib import Path
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
speech_file_path = Path(__file__).parent / "speech.mp3"
response = client.audio.speech.create(
model="openai/tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dogs"
)
response.stream_to_file(speech_file_path)
cURL
curl https://api.haimaker.ai/v1/audio/speech \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}' \
--output speech.mp3
Using Different Models
OpenAI TTS
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.audio.speech.create(
model="openai/tts-1",
voice="alloy", # Options: alloy, echo, fable, onyx, nova, shimmer
input="Hello, this is a test of text to speech."
)
response.stream_to_file("speech.mp3")
OpenAI TTS HD
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.audio.speech.create(
model="openai/tts-1-hd",
voice="nova",
input="This is high-definition text to speech."
)
response.stream_to_file("speech_hd.mp3")
Gemini TTS
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.audio.speech.create(
model="gemini/gemini-2.5-flash-preview-tts",
voice="alloy",
input="The quick brown fox jumped over the lazy dogs"
)
response.stream_to_file("gemini_speech.mp3")
Available Voices
For OpenAI TTS models, the available voices are:
| Voice | Description |
|---|---|
alloy | Neutral, balanced voice |
echo | Warm, conversational voice |
fable | Expressive, storytelling voice |
onyx | Deep, authoritative voice |
nova | Friendly, upbeat voice |
shimmer | Clear, professional voice |
Supported Providers
| Provider | Documentation Link |
|---|---|
| OpenAI | Usage |
| Azure OpenAI | Azure TTS |
| Vertex AI | Vertex AI TTS |
| ElevenLabs | ElevenLabs TTS |
| MiniMax | MiniMax TTS |